Generating your Form
So after spending all that time preparing your form object, what do you do? Generate the HTML of course!
Again, there are two ways to call the generate() method. This will wrap all elements in the object with <form> tags and return it as HTML ready to be place in your view.
This should be the last call you make to each goodform object. Anything other actions applied to the instance will have no effect after the form has been generated.
generate (string action)
- action: this is the action url of the form, like the site_url() helper relative paths will be turned into full site urls | optional
Example:
$this->goodform->generate('my_controller/do_form');
Will produce the following HTML:
<form action="http://www.example.com/my_controller/do_form">
// form contents
</form>
generate (array attributes)
- attributes: All attributes in this array will be converted to HTML element attributes. | optional
Example:
$attr = array(
'action' => 'my_controller/do_form',
'class' => 'goodform',
'method => 'put'
);
$this->goodform->generate($attr);
Will produce the following HTML:
<form action="http://www.example.com/my_controller/do_form" class="goodform" method="put">
// form contents
</form>