newhck / php-form-builder-class

Automatically exported from code.google.com/p/php-form-builder-class
GNU General Public License v3.0
0 stars 0 forks source link

Add function to fill the form with posted values #73

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I need a funtion that prefills the values of the form also if I checked the 
validation of the form.
If I check $form->validate() and the form is valid the values will be deleted.
Could someone make a function to prevent this behave or a function to fill the 
inputs again even if the form is valid?

Original issue reported on code.google.com by herrmast...@mailinator.com on 4 Sep 2010 at 4:37

GoogleCodeExporter commented 8 years ago
You can use the setValues function before you invoke the render function to 
pre-fill the form's default values.  The setValues function accepts an 
associative array where the array's keys match the form element names.  Below 
is a code snippet that should get your headed in the right direction.

$form = new form("myexample');
$form->setAttributes(array(
"width" => "400"
));

$form->setValues(array(
"mytextbox" => "My Textbox's Value",
"mydate" => date("F j, Y")
))

$form->addTextbox("My Textbox:", "mytextbox");
$form->addDate("My Date:", "mydate");

$form->addButton();
$form->render();

Original comment by ajporterfield@gmail.com on 4 Sep 2010 at 5:49

GoogleCodeExporter commented 8 years ago

Original comment by ajporterfield@gmail.com on 10 Sep 2010 at 1:38