/view/lib/helpers/form_helper.phpForm helpers
Set of functions for working with forms related to objects assigned to the template. All helpers are tailored for accessing an attribute (identified by $method) on an object assigned to the template (identified by $object). $object_name is used for generation of "id" and "name" attributes. Additional attributes for the tag can be passed as an array with $options. Some helpers have specific options too.
check_box
($object_name, $method, $object, $options = array(), $checked_value = '1', $unchecked_value = '0', $boolean = true)
Returns a checkbox tag.
By default, the checkbox will be checked if $method returns true. The $checked_value defaults to 1 while the default $unchecked_value is set to 0 because this value will be typecasted to a boolean by the Active Record. But if you set $boolean option to false, the checkbox will be checked only if $method returns $checked_value. Due to the fact that usually unchecked checkboxes don’t post anything, a hidden value is added with the same name as the checkbox. Example :
check_box('post', 'private', $this->post);
<input name="post[private]" type="hidden" value="0" />
<input checked="checked" id="post_private" name="post[private]" type="checkbox" value="1" />
default_options
($object_name, $method, $object, $options = array())
file_field
($object_name, $method, $object, $options = array())
Returns an input tag of the "file" type, which won't have a default value.
hidden_field
($object_name, $method, $object, $options = array())
Returns an input tag of the "hidden" type.
password_field
($object_name, $method, $object, $options = array())
Returns an input tag of the "password" type.
radio_button
($object_name, $method, $object, $tag_value, $options = array())
Returns a radio button tag.
The radio button will be checked if the current value of $method is equal to $tag_value. Example :
radio_button('post', 'title', $this->post, 'Hello World');
<input id="post_title_hello_world" name="post[title]" type="radio" value="Hello World" />
text_area
($object_name, $method, $object, $options = array())
Returns a textarea opening and closing tag set.
Example :
text_area('post', 'body', $this->post, array('cols' => 40, 'rows' => 10));
<textarea id="post_body" name="post[body]" cols="40" rows="10">
.....
</textarea>
text_field
($object_name, $method, $object, $options = array())
Returns an input tag of the "text" type.
Example ($this->post->title returns "PHP for ever") :
text_field('post', 'title', $this->post, array('size' => 35));
<input id="post_title" name="post[title]" size="35" type="text" value="PHP for ever" />
Documentation generated on Wed, 24 Jan 2007 14:54:50 +0100 by phpDocumentor 1.3.0RC4