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

Procedural File: form_options_helper.php

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





Page Details:

File containing the FormOptionsHelper class and support functions

(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$








collection_select [line 348]

void collection_select( mixed $object_name, mixed $attribute_name, mixed $collection, mixed $attribute_value, mixed $attribute_text, [mixed $options = array()], [mixed $html_options = array()])

Create a new FormOptionsHelper object and call its to_collection_select_tag() method

Return select and option tags for the given object and method using options_from_collection_for_select to generate the list of option tags.

Example with $post->person_id => 1: $person = new Person; $people = $person->find_all(); collection_select("post", "person_id", $people, "id", "first_name", array("include_blank" => true))

could become:

<select name="post[person_id]"> <option></option> <option value="1" selected="selected">David</option> <option value="2">Sam</option> <option value="3">Tobias</option> </select>




Tags:

uses:  FormOptionsHelper::to_collection_select_tag()
todo:  Document this function


[ Top ]



country_select [line 364]

void country_select( mixed $object_name, mixed $attribute_name, [mixed $priority_countries = null], [mixed $options = array()], [mixed $html_options = array()])

Create a new FormOptionsHelper object and call its to_country_select_tag() method

Return select and option tags for the given object and method, using country_options_for_select to generate the list of option tags.




Tags:

uses:  FormOptionsHelper::country_select()
todo:  Document this function


[ Top ]



options_for_select [line 376]

void options_for_select( string[] $choices, [integer $selected = null])

Create a new FormOptionsHelper object and call its options_for_select() method



Tags:



Parameters

string[]   $choices   List of choices
integer   $selected   Index of the selected choice
[ Top ]



select [line 319]

void select( mixed $object_name, mixed $attribute_name, mixed $choices, [mixed $options = array()], [mixed $html_options = array()])

Create a new FormOptionsHelper object and call its to_select_tag() method

Create a select tag and a series of contained option tags for the provided object and method. The option currently held by the object will be selected, provided that the object is available. See options_for_select for the required format of the choices parameter.

Example with $post->person_id => 1: $person = new Person; $people = $person->find_all(); foreach($people as $person) { $choices[$person->id] = $person->first_name; } select("post", "person_id", $choices, array("include_blank" => true))

could become:

<select name="post[person_id]"> <option></option> <option value="1" selected="selected">David</option> <option value="2">Sam</option> <option value="3">Tobias</option> </select>

This can be used to provide a functionault set of options in the standard way: before r}ering the create form, a new model instance is assigned the functional options and bound to




Tags:

todo:  Document this function


[ Top ]



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