function form_process_weight
form_process_weight($element)
Expands a weight element into a select element.
Related topics
File
- includes/form.inc, line 4112
- Functions for form and batch generation and processing.
Code
function form_process_weight($element) { $element['#is_weight'] = TRUE; // If the number of options is small enough, use a select field. $max_elements = variable_get('drupal_weight_select_max', DRUPAL_WEIGHT_SELECT_MAX); if ($element['#delta'] <= $max_elements) { $element['#type'] = 'select'; for ($n = (-1 * $element['#delta']); $n <= $element['#delta']; $n++) { $weights[$n] = $n; } $element['#options'] = $weights; $element += element_info('select'); } // Otherwise, use a text field. else { $element['#type'] = 'textfield'; // Use a field big enough to fit most weights. $element['#size'] = 10; $element['#element_validate'] = array('element_validate_integer'); $element += element_info('textfield'); } return $element; }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/includes!form.inc/function/form_process_weight/7.x