Ejemplo n.º 1
0
/**
 *  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>
 *
 *  @todo Document this function
 *  @uses FormOptionsHelper::to_collection_select_tag()
 */
function collection_select($object_name, $attribute_name, $collection, $attribute_value, $attribute_text, $options = array(), $html_options = array())
{
    $form = new FormOptionsHelper($object_name, $attribute_name);
    return $form->to_collection_select_tag($collection, $attribute_value, $attribute_text, $options, $html_options);
}