diff options
Diffstat (limited to 'includes/form.inc')
-rw-r--r-- | includes/form.inc | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/includes/form.inc b/includes/form.inc index e0bc9cba0..3d5f6f22e 100644 --- a/includes/form.inc +++ b/includes/form.inc @@ -16,7 +16,7 @@ * \@see user_pass_validate(). * \@see user_pass_submit(). * - * @} End of "defgroup forms". + * @} */ /** @@ -156,6 +156,8 @@ function drupal_get_form($form_id) { * automatically loaded by form_get_cache(). By default the current menu * router item's 'file' definition is added, if any. Use * form_load_include() to add include files from a form constructor. + * - base_form_id: Identification for a base form, as declared in a + * hook_forms() implementation. * - rebuild_info: Internal. Similar to 'build_info', but pertaining to * drupal_rebuild_form(). * - rebuild: Normally, after the entire form processing is completed and @@ -3349,6 +3351,13 @@ function form_process_machine_name($element, &$form_state) { 'replace' => '_', ); + // By default, machine names are restricted to Latin alphanumeric characters. + // So, default to LTR directionality. + if (!isset($element['#attributes'])) { + $element['#attributes'] = array(); + } + $element['#attributes'] += array('dir' => 'ltr'); + // The source element defaults to array('name'), but may have been overidden. if (empty($element['#machine_name']['source'])) { return $element; @@ -3786,13 +3795,27 @@ function theme_password($variables) { * Expand weight elements into selects. */ function form_process_weight($element) { - for ($n = (-1 * $element['#delta']); $n <= $element['#delta']; $n++) { - $weights[$n] = $n; - } - $element['#options'] = $weights; - $element['#type'] = 'select'; $element['#is_weight'] = TRUE; - $element += element_info('select'); + + // 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; } @@ -3976,7 +3999,7 @@ function theme_form_element_label($variables) { $t = get_t(); // If title and required marker are both empty, output no label. - if (empty($element['#title']) && empty($element['#required'])) { + if ((!isset($element['#title']) || $element['#title'] === '') && empty($element['#required'])) { return ''; } |