Kyttias
07-04-2014, 07:59 AM
Working here with v1.3.4, and I'm trying to recreate this, basically:
<form id="gamescore" action="" method="post">
<input type="hidden" value="100" name="amount" />
<button class="btn btn-default" id="sendtest">Click!</button>
</form>
I've tried echoing it out and, yeah, I can get it to appear just fine, I'm just not sure how to point the action attribute to the script I want to run. (A class file in the classes folder.) So I decided to go stare at what other pages are doing.
I see FormBuilder() working here:
$donateForm = new FormBuilder("donateform", "donate", "post");
$donateForm->buildComment("Donate to: ", FALSE)
->buildTextField("recipient")
->buildComment("Amount to donate: ", FALSE)
->buildTextField("amount")
->buildButton("Donate", "submit", "submit");
$document->add($donateForm);
Two questions come to mind...
The first variable in FormBuilder() seems to be the form's id, and the last one is the method. The middle seems to be the action, but that's not a php page it's linking to, that's just a mere word?? So I'm guessing FormBuilder automatically tacks on the .php extension, and, in that case, the form's action location is the one just in the root folder, not one inside classes. Is this right? Minimum, what do I need to set up a page in the root to run a function? Specifically something like~
public function gamescore() {
$mysidia = Registry::get("mysidia");
if($mysidia->input->post("amount")){
$amount = $mysidia->input->post("amount");
$this->money += $amount;
$mysidia->db->update("users", array("money" => $this->money), "username = '{$this->username}'");
$document->setTitle("Success");
$document->add(new Comment("Obtained {$amount} {$mysidia->settings->cost}!"));
$this->refresh(3);
return;
}
}
And even that may be terribly wrong, I won't know until I know my form is actually submitting somewhere.
The second question is harder, as I need to create an input field with type="hidden". I assume a type="text" is what has now become ->buildTextField, so what is the equivalent for hidden input fields?
Note that I also need the FormBuilder() to add on class and id attributes to the button, too, please? I'd also like insight on how to add classes to various things in Mysidia through the architecture given to us, rather than having to hack it in later with jQuery.
<form id="gamescore" action="" method="post">
<input type="hidden" value="100" name="amount" />
<button class="btn btn-default" id="sendtest">Click!</button>
</form>
I've tried echoing it out and, yeah, I can get it to appear just fine, I'm just not sure how to point the action attribute to the script I want to run. (A class file in the classes folder.) So I decided to go stare at what other pages are doing.
I see FormBuilder() working here:
$donateForm = new FormBuilder("donateform", "donate", "post");
$donateForm->buildComment("Donate to: ", FALSE)
->buildTextField("recipient")
->buildComment("Amount to donate: ", FALSE)
->buildTextField("amount")
->buildButton("Donate", "submit", "submit");
$document->add($donateForm);
Two questions come to mind...
The first variable in FormBuilder() seems to be the form's id, and the last one is the method. The middle seems to be the action, but that's not a php page it's linking to, that's just a mere word?? So I'm guessing FormBuilder automatically tacks on the .php extension, and, in that case, the form's action location is the one just in the root folder, not one inside classes. Is this right? Minimum, what do I need to set up a page in the root to run a function? Specifically something like~
public function gamescore() {
$mysidia = Registry::get("mysidia");
if($mysidia->input->post("amount")){
$amount = $mysidia->input->post("amount");
$this->money += $amount;
$mysidia->db->update("users", array("money" => $this->money), "username = '{$this->username}'");
$document->setTitle("Success");
$document->add(new Comment("Obtained {$amount} {$mysidia->settings->cost}!"));
$this->refresh(3);
return;
}
}
And even that may be terribly wrong, I won't know until I know my form is actually submitting somewhere.
The second question is harder, as I need to create an input field with type="hidden". I assume a type="text" is what has now become ->buildTextField, so what is the equivalent for hidden input fields?
Note that I also need the FormBuilder() to add on class and id attributes to the button, too, please? I'd also like insight on how to add classes to various things in Mysidia through the architecture given to us, rather than having to hack it in later with jQuery.