Révision b4adf10d
Ajouté par Assos Assos il y a plus de 9 ans
drupal7/includes/form.inc | ||
---|---|---|
2699 | 2699 |
} |
2700 | 2700 |
|
2701 | 2701 |
/** |
2702 |
* Converts a select form element's options array into HTML. |
|
2703 |
* |
|
2704 |
* @param $element |
|
2705 |
* An associative array containing the properties of the element. |
|
2706 |
* @param $choices |
|
2707 |
* Mixed: Either an associative array of items to list as choices, or an |
|
2708 |
* object with an 'option' member that is an associative array. This |
|
2709 |
* parameter is only used internally and should not be passed. |
|
2710 |
* |
|
2711 |
* @return |
|
2712 |
* An HTML string of options for the select form element. |
|
2702 |
* Converts an array of options into HTML, for use in select list form elements. |
|
2703 |
* |
|
2704 |
* This function calls itself recursively to obtain the values for each optgroup |
|
2705 |
* within the list of options and when the function encounters an object with |
|
2706 |
* an 'options' property inside $element['#options']. |
|
2707 |
* |
|
2708 |
* @param array $element |
|
2709 |
* An associative array containing the following key-value pairs: |
|
2710 |
* - #multiple: Optional Boolean indicating if the user may select more than |
|
2711 |
* one item. |
|
2712 |
* - #options: An associative array of options to render as HTML. Each array |
|
2713 |
* value can be a string, an array, or an object with an 'option' property: |
|
2714 |
* - A string or integer key whose value is a translated string is |
|
2715 |
* interpreted as a single HTML option element. Do not use placeholders |
|
2716 |
* that sanitize data: doing so will lead to double-escaping. Note that |
|
2717 |
* the key will be visible in the HTML and could be modified by malicious |
|
2718 |
* users, so don't put sensitive information in it. |
|
2719 |
* - A translated string key whose value is an array indicates a group of |
|
2720 |
* options. The translated string is used as the label attribute for the |
|
2721 |
* optgroup. Do not use placeholders to sanitize data: doing so will lead |
|
2722 |
* to double-escaping. The array should contain the options you wish to |
|
2723 |
* group and should follow the syntax of $element['#options']. |
|
2724 |
* - If the function encounters a string or integer key whose value is an |
|
2725 |
* object with an 'option' property, the key is ignored, the contents of |
|
2726 |
* the option property are interpreted as $element['#options'], and the |
|
2727 |
* resulting HTML is added to the output. |
|
2728 |
* - #value: Optional integer, string, or array representing which option(s) |
|
2729 |
* to pre-select when the list is first displayed. The integer or string |
|
2730 |
* must match the key of an option in the '#options' list. If '#multiple' is |
|
2731 |
* TRUE, this can be an array of integers or strings. |
|
2732 |
* @param array|null $choices |
|
2733 |
* (optional) Either an associative array of options in the same format as |
|
2734 |
* $element['#options'] above, or NULL. This parameter is only used internally |
|
2735 |
* and is not intended to be passed in to the initial function call. |
|
2736 |
* |
|
2737 |
* @return string |
|
2738 |
* An HTML string of options and optgroups for use in a select form element. |
|
2713 | 2739 |
*/ |
2714 | 2740 |
function form_select_options($element, $choices = NULL) { |
2715 | 2741 |
if (!isset($choices)) { |
... | ... | |
3285 | 3311 |
*/ |
3286 | 3312 |
function theme_container($variables) { |
3287 | 3313 |
$element = $variables['element']; |
3314 |
// Ensure #attributes is set. |
|
3315 |
$element += array('#attributes' => array()); |
|
3288 | 3316 |
|
3289 | 3317 |
// Special handling for form elements. |
3290 | 3318 |
if (isset($element['#array_parents'])) { |
Formats disponibles : Unified diff
Udpate to 7.33