[ Index ]
 

Code source de PHPonTrax 2.6.6-svn

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/vendor/trax/action_view/helpers/ -> form_options_helper.php (sommaire)

File containing the FormOptionsHelper class and support functions (PHP 5)

Copyright: (c) 2005 John Peterson
Version: $Id: form_options_helper.php 243 2006-08-23 05:25:24Z john $
Poids: 391 lignes (17 kb)
Inclus ou requis: 1 fois
Référencé: 0 fois
Nécessite: 0 fichiers

Définit 1 class

FormOptionsHelper:: (11 méthodes):
  options_for_select()
  options_from_collection_for_select()
  country_options_for_select()
  to_select_tag()
  to_collection_select_tag()
  to_country_select_tag()
  add_options()
  select()
  collection_select()
  country_select()
  options_for_select()


Classe: FormOptionsHelper  - X-Ref


options_for_select($choices, $selected = null)   X-Ref
Generate HTML option tags from a list of choices

Accepts an array of possible choices and returns a string of
option tags.  The value of each array element becomes the
visible text of an option, and the key of the element becomes
the value returned to the server.  For example:<br />
<samp>options_for_select(array('foo','bar'));</samp><br />
will return:<br />
<samp><option value="0">foo</option>\n</samp><br />
<samp><option value="1">bar</option></samp><br />

The optional second argument specifies the array key of an
option to be initially selected.

NOTE: Only the option tags are returned, you have to wrap this
call in a regular HTML select tag.
param: string[]  Choices
param: integer   Selected choice
return: string

options_from_collection_for_select($collection, $attribute_value,$attribute_text,$selected_value = null)   X-Ref
Returns a string of option tags that have been compiled by
iterating over the +collection+ and assigning the result of a
call to the +value_method+ as the option value and the
+text_method+ as the option text. If +selected_value+ is
specified, the element returning a match on +value_method+ 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:
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.

country_options_for_select($selected = null,$priority_countries = array()   X-Ref
Generate HTML options for world countries

param: integer  Array key of country initially selected

to_select_tag($choices, $options, $html_options)   X-Ref


to_collection_select_tag($collection, $attribute_value,$attribute_text, $options,$html_options)   X-Ref


to_country_select_tag($priority_countries,$options, $html_options)   X-Ref


add_options($option_tags, $options)   X-Ref

param: string
param: array

select($object_name, $attribute_name, $choices,$options = array()   X-Ref
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

collection_select($object_name, $attribute_name, $collection,$attribute_value, $attribute_text,$options = array()   X-Ref
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>


country_select($object_name, $attribute_name, $priority_countries = null, $options = array()   X-Ref
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.

options_for_select($choices, $selected = null)   X-Ref
Create a new FormOptionsHelper object and call its options_for_select() method

param: string[]  List of choices
param: integer   Index of the selected choice



Généré le : Sun Feb 25 20:04:38 2007 par Balluche grâce à PHPXref 0.7