File/view/lib/helpers/form_options_helper.php

Description

Form options helpers

Functions
collection_select ($object_name, $method, $object, $collection, $value_prop = 'id', $text_prop = null, $options = array(), $html_options = array())

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

options_for_select ($set, $selected = null, $detect_non_associative = true)

Accepts an array and returns a string of option tags.

Examples :

 options_for_select(array('Margharita', 'Calzone', 'Napolitaine'));
 // returns :
  <option value="Margharita">Margharita</option>
 <option value="Calzone">Calzone</option>
 <option value="Napolitaine">Napolitaine</option>
 
 options_for_select(array('Margharita'=>'7€', 'Calzone'=>'9€', 'Napolitaine'=>'8€'));
 // returns :
  <option value="7€">Margharita</option>
 <option value="9€">Calzone</option>
 <option value="8€">Napolitaine</option>

options_from_collection_for_select ($collection, $value_prop = 'id', $text_prop = null, $selected = null)

Returns a string of option tags that have been compiled by iterating over the $collection and assigning the value of the $value_prop property as the option value and the value of the $text_prop property as the option text.

Examples :

 options_from_collection_for_select($this->company->employes, 'id', 'name');
 // => returns the equivalent of:
  <option value="{$employe->id}">{$employe->name}</option>
 ...

select ($object_name, $method, $object, $choices, $options = array(), $html_options = array())

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. See options_for_select for the required format of the $choices argument.

Example :

 select('post', 'category', Post::$categories, array('include_blank' => True));
could generate :
 <select id="post_category" name="post[category]">
   <option></option>
   <option>PHP</option>
   <option>Linux</option>
   <option>Space</option>
 </select>

Documentation generated on Wed, 24 Jan 2007 14:54:50 +0100 by phpDocumentor 1.3.0RC4