===== Select =====
==== select ====
**Syntax:**\\
$form_options_helper->select ($object_name,$column_name,$choices,
[ $options ],[ $html_options ])
**Description:**\\
Creates 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.
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.\\
* ''$choices'' is defined in the API as the function ''$form_options_helper->options_for_select''. It is this array: ''( $container, [ $selected = array()], [ $options = array()])''.
* ''$container'' is an array of the values and keys (notice the reverse order) that go into the ''option'' tags. Array('Dollar'=>'$', 'Kroner'=>'DKK') will yield
*''$selected'' specifies which container item will be selected. It is an array, so that more than one value may be selected in the case of a multiple select.\\
**Examples of ''$choices'':**
* (array('VISA', 'MasterCard'), 'MasterCard');yields
* (array('Basic'=>'$20','Plus'=>'$40'), '$40');yields
* (array('VISA','MasterCard','Discover'), array('VISA','Discover'));yields
* ''$options = array()'' Two mutually exclusive options are:\\
* '''include_blank' => true'' This causes the first option element to be blank.
* '''prompt' => true'' This causes the first option element to be a prompt string. Set to //true// will give a generic "Please select", alternatively you can enter your own text as a value. (Note: the default 'Please select' can be localized. It's in /locales/helpers/form/) \\
* ''$html_options = array()''\\ \\
**Example:**
$form_options_helper->select(
'post', $object_name
'person_id', $column_name
$Person->collect($Person->find(), 'name', 'id'), $choices
array('include_blank'=>true)); $options
$html_options have been omitted
Example notes:
* **$choices**:
''$Person'' is a class referring to the ''people'' table. This table ''belongs_to'' the ''$object_name''.
* **selected**:
''$post.person_id'' is the selected option, by default. To select 'identifier' as the the option, the ''$options'' clause would be modified to look like this:\\
array('include_blank'=>true,'selected' => $post.identifier));
If you wish to have no option selected, the ''$options'' clause would look like this:\\
array('include_blank'=>true,'selected' => null));
**Example:**\\
$form_options_helper->select('post','category', $Post->categories, array('include_blank'=>true));\\
==== select_tag ====
**Syntax:**\\
$form_tag_helper->select_tag($name,[ $option_tags],[ $options ])
**Description:**\\
Creates a dropdown selection box, or if the 'multiple' => true, a multiple choice selection box.\\
$option_tags is a string containing the option tags for the select box:\\
$options array:
* '''multiple' => true'' - If set to true the selection will allow multiple choices.
* '''include_blank' => true'' This causes the first option element to be blank.
* '''prompt' => true'' This causes the first option element to be a prompt string. Set to //true// will give a generic "Please select", alternatively you can enter your own text as a value. (Note: the default 'Please select' can be localized. It's in /locales/helpers/form/) \\ \\
**Example:**\\
$form_tag_helper->select_tag('people', '');
produces
==== collection_select ====
**Syntax:**\\
$form_options_helper->collection_select($object_name,$column_name,$collection,
$value_column_name,$text_column_name,[ $selected_value ],[ $options ],[ $html_options ])
**Description:**\\
Returns select and option tags for the given object and column_name that have been compiled by iterating over the ''$collection'' and assigning the the result of a call to the ''$value_column_name'' and the ''$text_column_name''.\\
* ''$selected_value'' If it is specified, it will be matched against the contents of the ''$value_column_name'' to determine the selected option tag.
* ''$collection'', ''$value_column_name'', ''$text_column_name'', ''$selected_value'', ''$options'', and ''$html_options'' are all arrays. The fact that ''$selected_value'' is an array means that more than one value may be selected in the case of a multiple select.\\
* ''$options = array()'' Two mutually exclusive options are:\\
* '' 'include_blank' => true'' Causes the first option element to be blank.
* '' 'prompt' => true'' This causes the first option element to be a prompt string. Set to //true// will give a generic "Please select", alternatively you can enter your own text as a value. (Note: the default 'Please select' can be localized. It's in /locales/helpers/form/) \\
* ''$html_options = array()''\\ \\
=== option_groups_from_collection_for_select ===
**Syntax:**\\
$form_options_helper->option_groups_from_collection_for_select(
$collection,$group_method,$group_label_method,$option_key_method,$option_value_method,[ $selected_key ])
**Description:**\\
Returns a string of option tags surrounded by