PHPonTrax
[ class tree: PHPonTrax ] [ index: PHPonTrax ] [ all elements ]

Procedural File: form_helper.php

Source Location: /vendor/trax/action_view/helpers/form_helper.php



Classes:

FormHelper


Page Details:

File containing the FormHelper class

(PHP 5)




Tags:

filesource:  Source Code for this file
copyright:  

(c) 2005 John Peterson

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

version:  $Id$








boolean_select [line 419]

void boolean_select( mixed $object, mixed $field, [mixed $options = array()])

Make a new FormHelper object and call its to_boolean_select_tag method



Tags:



[ Top ]



check_box [line 392]

void check_box( mixed $object, mixed $field, [mixed $options = array()], [mixed $checked_value = "1"], [mixed $unchecked_value = "0"])

Returns a checkbox tag tailored for accessing a specified attribute (identified by $field) on an object

assigned to the template (identified by $object). It's intended that $field returns an integer and if that integer is above zero, then the checkbox is checked. Additional $options on the input tag can be passed as an array with $options. The $checked_value defaults to 1 while the default $unchecked_value is set to 0 which is convenient for boolean values. Usually unchecked checkboxes don't post anything. We work around this problem by adding a hidden value with the same name as the checkbox. Example: Imagine that $post->validated is 1: check_box("post", "validated"); Result: <input type="checkbox" id="post_validate" name="post[validated] value="1" checked="checked" /> <input name="post[validated]" type="hidden" value="0" /> Example: Imagine that $puppy->gooddog is no: check_box("puppy", "gooddog", array(), "yes", "no"); Result: <input type="checkbox" id="puppy_gooddog" name="puppy[gooddog] value="yes" /> <input name="puppy[gooddog]" type="hidden" value="no" />




Tags:



[ Top ]



file_field [line 356]

void file_field( mixed $object, mixed $field, [mixed $options = array()])

Works just like text_field, but returns a input tag of the "file" type instead, which won't have any default value.



Tags:



[ Top ]



hidden_field [line 347]

void hidden_field( mixed $object, mixed $field, [mixed $options = array()])

Works just like text_field, but returns a input tag of the "hidden" type instead.

Example: hidden_field("post", "title"); Result: <input type="hidden" id="post_title" name="post[title]" value="$post->title" />




Tags:



[ Top ]



password_field [line 336]

void password_field( mixed $object, mixed $field, [mixed $options = array()])

Works just like text_field, but returns a input tag of the "password" type instead.

Example: password_field("user", "password"); Result: <input type="password" id="user_password" name="user[password]" value="$user->password" />




Tags:



[ Top ]



radio_button [line 410]

void radio_button( mixed $object, mixed $field, mixed $tag_value, [mixed $options = array()])

Returns a radio button tag for accessing a specified attribute (identified by $field) on an object assigned to the template (identified by $object). If the current value of $field is $tag_value the radio button will be checked. Additional $options on the input tag can be passed as a hash with $options.

Example: Imagine that $post->category is "trax": radio_button("post", "category", "trax"); radio_button("post", "category", "java"); Result: <input type="radio" id="post_category" name="post[category] value="trax" checked="checked" /> <input type="radio" id="post_category" name="post[category] value="java" />




Tags:



[ Top ]



text_area [line 366]

void text_area( mixed $object, mixed $field, [mixed $options = array()])

Example: text_area("post", "body", array("cols" => 20, "rows" => 40));

Result: <textarea cols="20" rows="40" id="post_body" name="post[body]">$post->body</textarea>




Tags:



[ Top ]



text_field [line 325]

void text_field( string $object, string $field, [string[] $options = array()])

Generate HTML/XML for <input type="text" /> in a view file

Example: In the view file, code

  1. <?= text_field("Person", "fname"); ?>
Result: <input id="Person_fname" name="Person[fname]" size="30" type="text" value="$Person->fname" />




Tags:



Parameters

string   $object   Class name of the object being processed
string   $field   Name of attribute in the object being processed
string[]   $options   Attributes to apply to the generated input tag as:
array('attr1' => 'value1'[, 'attr2' => 'value2']...)
[ Top ]



Documentation generated on Thu, 04 May 2006 19:47:36 -0600 by phpDocumentor 1.3.0RC4