| [ Index ] |
PHP Cross Reference of Akelos Framework |
[Source view] [Print]
(no description)
| Author: | Bermi Ferrer |
| Copyright: | Copyright (c) 2002-2006, Akelos Media, S.L. http://www.akelos.org |
| License: | GNU Lesser General Public License |
| File Size: | 428 lines (21 kb) |
| Included or required: | 0 times |
| Referenced: | 0 times |
| Includes or requires: | 3 files AkLocalize/AkTimeZone.php AkActionView/helpers/form_helper.php AkLocalize/AkCountries.php |
FormOptionsHelper:: (9 methods):
select()
collection_select()
country_select()
time_zone_select()
options_for_select()
options_from_collection_for_select()
option_groups_from_collection_for_select()
country_options_for_select()
time_zone_options_for_select()
AkFormHelperOptionsInstanceTag:: (6 methods):
AkFormHelperOptionsInstanceTag()
to_select_tag()
to_collection_select_tag()
to_country_select_tag()
to_time_zone_select_tag()
_addOptions()
AkFormOptionsHelperBuilder:: (5 methods):
AkFormOptionsHelperBuilder()
select()
collection_select()
country_select()
time_zone_select()
Class: FormOptionsHelper - X-Ref
Provides a number of methods for turning different kinds of containers into a set of option tags.| select($object_name, $column_name, $choices, $options = array() X-Ref |
| 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: $form_options_helper->select('post', 'person_id', $Person->collect($Person->find(), 'name', 'id'), array(), 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 default set of options in the standard way: before rendering the create form, a new model instance is assigned the default options and bound to $this->model_name. Usually this model is not saved to the database. Instead, a second model object is created when the create request is received. This allows the user to submit a form page more than once with the expected results of creating multiple records. In addition, this allows a single partial to be used to generate form inputs for both edit and create forms. By default, $post.person_id is the selected option. Specify 'selected' => value to use a different selection or 'selected' => null to leave all options unselected. |
| collection_select($object_name, $column_name, $collection, $value_column_name, $text_column_name, $options = array() X-Ref |
| Return select and option tags for the given object and column_name using options_from_collection_for_select to generate the list of option tags. |
| country_select($object_name, $column_name, $priority_countries = null, $options = array() X-Ref |
| Return select and option tags for the given object and column_name, using country_options_for_select to generate the list of option tags. |
| time_zone_select($object_name, $column_name, $priority_zones = array() X-Ref |
| Return select and option tags for the given object and column_name, using #time_zone_options_for_select to generate the list of option tags. In addition to the <tt>include_blank</tt> option documented above, this method also supports a <tt>model</tt> option, which defaults to TimeZone. This may be used by users to specify a different time zone model object. (See #time_zone_options_for_select for more information.) |
| options_for_select($container, $selected = array() X-Ref |
| Accepts a container array and returns a string of option tags. Given a container where the elements respond to first and last (such as a two-element array), the "lasts" serve as option values and the "firsts" as option text. Arrays are turned into this form automatically, so the keys become "firsts" and values become lasts. If +selected+ is specified, the matching "last" or element will get the selected option-tag. +Selected+ may also be an array of values to be selected when using a multiple select. Examples (call, result): $form_options_helper->options_for_select(array('Dollar'=>'$', 'Kroner'=>'DKK')); <option value="$">Dollar</option><option value="DKK">Kroner</option> $form_options_helper->options_for_select(array('VISA', 'MasterCard'), 'MasterCard'); <option value="VISA">VISA</option><option selected="selected" value="MasterCard">MasterCard</option> $form_options_helper->options_for_select(array('Basic'=>'$20','Plus'=>'$40'), '$40'); <option value="$20">Basic</option><option selected="selected" value="$40">Plus</option> $form_options_helper->options_for_select(array('VISA','MasterCard','Discover'), array('VISA','Discover')); <option selected="selected" value="VISA">VISA</option> <option value="MasterCard">MasterCard</option> <option selected="selected" value="Discover">Discover</option> NOTE: Only the option tags are returned, you have to wrap this call in a regular HTML select tag. |
| options_from_collection_for_select($collection, $value_column_name, $text_column_name = null, $selected_value = array() X-Ref |
| Returns a string of option tags that have been compiled by iterating over the +collection+ and assigning the the result of a call to the +value_column_name+ as the option value and the +text_column_name+ as the option text. If +$selected_value+ is specified, the element returning a match on +value_column_name+ will get the selected option tag. Example (call, result). Imagine a loop iterating over each +person+ in <tt>$Project->People</tt> to generate an input tag: $form_options_helper->options_from_collection_for_select($Project->People,'id','name'); <option value="{$Person->id}">{$Person->name}</option> NOTE: Only the option tags are returned, you have to wrap this call in a regular HTML select tag. |
| option_groups_from_collection_for_select($collection, $group_method, $group_label_method, $option_key_method, $option_value_method, $selected_key = null) X-Ref |
| Returns a string of option tags, like options_from_collection_for_select, but surrounds them with <optgroup> tags. An array of group objects are passed. Each group should return an array of options when calling group_method Each group should return its name when calling group_label_method. $form_options_helper->option_groups_from_collection_for_select($continents, 'getCountries', 'getContinentName', 'getCountryId', 'getCountryName', $selected_country->id); Could become: <optgroup label="Africa"> <option value="EGP">Egipt</option> <option value="RWD">Rwanda</option> .... </optgroup> <optgroup label="Asia"> <option value="ZHN">China</option> <option value="IND">India</option> <option selected="selected" value="JPN">Japan</option> ..... </optgroup> with objects of the following classes: class Continent{ function Continent($p_name, $p_countries){ $this->continent_name = $p_name; $this->countries = $p_countries;} function getContinentName(){ return $this->continent_name; } function getCountries(){ return $this->countries; } } class Country { function Country($id, $name){ $this->id = $id; $this->name = $name; } function getCountryId(){ return $this->id; } function getCountryName(){ return $this->name;} } NOTE: Only the option tags are returned, you have to wrap this call in a regular HTML select tag. |
| country_options_for_select($selected = null, $priority_countries = array() X-Ref |
| Returns a string of option tags for pretty much any country in the world. Supply a country name as +selected+ to have it marked as the selected option tag. You can also supply an array of countries as +priority_countries+, so that they will be listed above the rest of the (long) list. NOTE: Only the option tags are returned, you have to wrap this call in a regular HTML select tag. |
| time_zone_options_for_select($selected = null, $priority_zones = array() X-Ref |
| Returns a string of option tags for pretty much any time zone in the world. Supply a TimeZone name as +selected+ to have it marked as the selected option tag. You can also supply an array of TimeZones as +$priority_zones+, so that they will be listed above the rest of the (long) list. The +selected+ parameter must be either +null+, or a string that names a TimeZone. By default, +model+ is an AkTimeZone instance. The only requirement is that the +model+ parameter be an object that responds to #all, and returns an object with a toString() method and the TimeZone name provided by a 'name' attribute For a list of supported timezones see: http://www.php.net/manual/en/timezones.php NOTE: Only the option tags are returned, you have to wrap this call in a regular HTML select tag. |
Class: AkFormHelperOptionsInstanceTag - X-Ref
| AkFormHelperOptionsInstanceTag($object_name, $column_name, &$template_object, $local_binding = null, &$object) X-Ref |
| No description |
| to_select_tag($choices, $options=array() X-Ref |
| No description |
| to_collection_select_tag($collection, $value_column_name, $text_column_name = null, $options = array() X-Ref |
| No description |
| to_country_select_tag($priority_countries = array() X-Ref |
| No description |
| to_time_zone_select_tag($priority_zones = array() X-Ref |
| No description |
| _addOptions($option_tags, $options, $value = null) X-Ref |
| No description |
Class: AkFormOptionsHelperBuilder - X-Ref
| AkFormOptionsHelperBuilder($object_name, $object, &$template) X-Ref |
| No description |
| select($column_name, $choices, $options = array() X-Ref |
| No description |
| collection_select($column_name, $collection, $value_column_name, $text_column_name, $options = array() X-Ref |
| No description |
| country_select($column_name, $priority_countries = null, $options = array() X-Ref |
| No description |
| time_zone_select($column_name, $priority_zones = null, $options = array() X-Ref |
| No description |
| Generated: Mon Oct 27 12:43:49 2008 | Cross-referenced by PHPXref 0.6 |