diff --git a/core/includes/form.inc b/core/includes/form.inc index 1c73977..0dc2ab2 100644 --- a/core/includes/form.inc +++ b/core/includes/form.inc @@ -1856,22 +1856,6 @@ function form_builder($form_id, &$element, &$form_state) { '#title_display' => 'before', ); - // Checks if the element needs property validation. - if (isset($element['#property_validate']) && is_array($element['#property_validate'])) { - // Validates required properties. - foreach ($element['#property_validate'] as $property => $callbacks) { - foreach ($callbacks as $callback) { - if (!isset($element[$property]) || !$callback($element)) { - trigger_error(t("'@type' element in form '@form_id' has a non-valid '@property' property.", array( - '@type' => $element['#type'], - '@form_id' => $form_id, - '@property' => $property, - )), E_USER_ERROR); - } - } - } - } - // Special handling if we're on the top level form element. if (isset($element['#type']) && $element['#type'] == 'form') { if (!empty($element['#https']) && settings()->get('mixed_mode_sessions', FALSE) && @@ -1923,6 +1907,23 @@ function form_builder($form_id, &$element, &$form_state) { $element['#processed'] = TRUE; } + // Checks if the element needs property validation. + if (isset($element['#property_validate']) && is_array($element['#property_validate'])) { + // Validates required properties. + foreach ($element['#property_validate'] as $property => $callbacks) { + foreach ($callbacks as $callback) { + if (!isset($element[$property]) || !$callback($element)) { + trigger_error(t("'@type' element in form '@form_id' has a non-valid '@property' property in @parents.", array( + '@type' => $element['#type'], + '@form_id' => $form_id, + '@property' => $property, + '@parents' => '$form[\'' . implode('\'][\'', $element['#parents']) . '\']', + )), E_USER_ERROR); + } + } + } + } + // We start off assuming all form elements are in the correct order. $element['#sorted'] = TRUE; @@ -3616,6 +3617,7 @@ function form_process_tableselect($element) { '#parents' => $element['#parents'], '#id' => drupal_html_id('edit-' . implode('-', $parents_for_id)), '#ajax' => isset($element['#ajax']) ? $element['#ajax'] : NULL, + '#property_validate' => array(), ); } if (isset($element['#options'][$key]['#weight'])) { diff --git a/core/modules/action/lib/Drupal/action/ActionFormControllerBase.php b/core/modules/action/lib/Drupal/action/ActionFormControllerBase.php index ff48164..f14b05f 100644 --- a/core/modules/action/lib/Drupal/action/ActionFormControllerBase.php +++ b/core/modules/action/lib/Drupal/action/ActionFormControllerBase.php @@ -79,7 +79,6 @@ public function form(array $form, array &$form_state) { $form['id'] = array( '#type' => 'machine_name', - '#title' => t('Machine name'), '#default_value' => $this->entity->id(), '#disabled' => !$this->entity->isNew(), '#maxlength' => 64, diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeFormController.php b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeFormController.php index c9029a3..cf88f5d 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeFormController.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeFormController.php @@ -31,7 +31,6 @@ public function form(array $form, array &$form_state) { ); $form['id'] = array( '#type' => 'machine_name', - '#title' => t('Machine name'), '#default_value' => $block_type->id(), '#machine_name' => array( 'exists' => 'custom_block_type_load', diff --git a/core/modules/block/lib/Drupal/block/BlockFormController.php b/core/modules/block/lib/Drupal/block/BlockFormController.php index f562a68..8e25268 100644 --- a/core/modules/block/lib/Drupal/block/BlockFormController.php +++ b/core/modules/block/lib/Drupal/block/BlockFormController.php @@ -29,7 +29,6 @@ public function form(array $form, array &$form_state) { $form['machine_name'] = array( '#type' => 'machine_name', - '#title' => t('Machine name'), '#maxlength' => 64, '#description' => t('A unique name to save this block configuration. Must be alpha-numeric and be underscore separated.'), '#default_value' => $entity->id(), diff --git a/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeFormBase.php b/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeFormBase.php index 787432a..615448f 100644 --- a/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeFormBase.php +++ b/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeFormBase.php @@ -73,7 +73,6 @@ public function form(array $form, array &$form_state) { $form['id'] = array( '#type' => 'machine_name', - '#title' => t('Machine-readable name'), '#description' => t('A unique machine-readable name. Can only contain lowercase letters, numbers, and underscores.'), '#disabled' => !$this->entity->isNew(), '#default_value' => $this->entity->id(), diff --git a/core/modules/node/lib/Drupal/node/NodeTypeFormController.php b/core/modules/node/lib/Drupal/node/NodeTypeFormController.php index 251eea4..ec465e1 100644 --- a/core/modules/node/lib/Drupal/node/NodeTypeFormController.php +++ b/core/modules/node/lib/Drupal/node/NodeTypeFormController.php @@ -49,7 +49,6 @@ public function form(array $form, array &$form_state) { $form['type'] = array( '#type' => 'machine_name', - '#title' => t('Machine name'), '#default_value' => $type->id(), '#maxlength' => 32, '#disabled' => $type->isLocked(), diff --git a/core/modules/system/lib/Drupal/system/Form/DateFormatFormBase.php b/core/modules/system/lib/Drupal/system/Form/DateFormatFormBase.php index 4d347c5..5c22f7c 100644 --- a/core/modules/system/lib/Drupal/system/Form/DateFormatFormBase.php +++ b/core/modules/system/lib/Drupal/system/Form/DateFormatFormBase.php @@ -132,7 +132,6 @@ public function form(array $form, array &$form_state) { $form['id'] = array( '#type' => 'machine_name', - '#title' => t('Machine-readable name'), '#description' => t('A unique machine-readable name. Can only contain lowercase letters, numbers, and underscores.'), '#disabled' => !$this->entity->isNew(), '#default_value' => $this->entity->id(), diff --git a/core/modules/system/tests/modules/ajax_forms_test/ajax_forms_test.module b/core/modules/system/tests/modules/ajax_forms_test/ajax_forms_test.module index 1682c01..80653da 100644 --- a/core/modules/system/tests/modules/ajax_forms_test/ajax_forms_test.module +++ b/core/modules/system/tests/modules/ajax_forms_test/ajax_forms_test.module @@ -49,6 +49,7 @@ function ajax_forms_test_simple_form($form, &$form_state) { $form = array(); $form['select'] = array( + '#title' => t('Color'), '#type' => 'select', '#options' => array( 'red' => 'red', diff --git a/core/modules/user/user.admin.inc b/core/modules/user/user.admin.inc index bb486ff..1fafdb0 100644 --- a/core/modules/user/user.admin.inc +++ b/core/modules/user/user.admin.inc @@ -4,6 +4,7 @@ * @file * Admin page callback file for the user module. */ +use Drupal\Component\Utility\String; /** * Page callback: User administration page. @@ -143,7 +144,7 @@ function user_admin_permissions($form, $form_state, $rid = NULL) { 'restrict access' => FALSE, 'warning' => !empty($perm_item['restrict access']) ? t('Warning: Give to trusted roles only; this permission has security implications.') : '', ); - $options[$perm] = ''; + $options[$perm] = $perm_item['title']; $user_permission_description = array( '#theme' => 'user_permission_description', '#permission_item' => $perm_item, @@ -167,6 +168,7 @@ function user_admin_permissions($form, $form_state, $rid = NULL) { // Have to build checkboxes here after checkbox arrays are built foreach ($role_names as $rid => $name) { $form['checkboxes'][$rid] = array( + '#title' => String::checkPlain($name), '#type' => 'checkboxes', '#options' => $options, '#default_value' => isset($status[$rid]) ? $status[$rid] : array(), @@ -229,6 +231,7 @@ function theme_user_admin_permissions($variables) { $form['checkboxes'][$rid][$key]['#title_display'] = 'invisible'; $row[] = array('data' => drupal_render($form['checkboxes'][$rid][$key]), 'class' => array('checkbox')); } + hide($form['checkboxes']); } $rows[] = $row; } diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/display/PathPluginBase.php b/core/modules/views/lib/Drupal/views/Plugin/views/display/PathPluginBase.php index 57691f1..79795d2 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/display/PathPluginBase.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/display/PathPluginBase.php @@ -305,6 +305,7 @@ public function buildOptionsForm(&$form, &$form_state) { $form['#title'] .= t('The menu path or URL of this view'); $form['path'] = array( '#type' => 'textfield', + '#title' => t('Path'), '#description' => t('This view will be displayed by visiting this path on your site. You may use "%" in your URL to represent values that will be used for contextual filters: For example, "node/%/feed".'), '#default_value' => $this->getOption('path'), '#field_prefix' => '' . url(NULL, array('absolute' => TRUE)), diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/filter/FilterPluginBase.php b/core/modules/views/lib/Drupal/views/Plugin/views/filter/FilterPluginBase.php index 60ba107..aa40b27 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/filter/FilterPluginBase.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/filter/FilterPluginBase.php @@ -8,6 +8,7 @@ namespace Drupal\views\Plugin\views\filter; use Drupal\views\Plugin\views\HandlerBase; +use Drupal\Component\Utility\String; use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\Component\Annotation\Plugin; use Drupal\views\ViewExecutable; @@ -748,6 +749,7 @@ public function groupForm(&$form, &$form_state) { $value = $this->options['group_info']['identifier']; $form[$value] = array( + '#title' => String::checkPlain($this->options['group_info']['label']), '#type' => $this->options['group_info']['widget'], '#default_value' => $this->group_info, '#options' => $groups, @@ -788,10 +790,6 @@ public function buildExposedForm(&$form, &$form_state) { $this->operatorForm($form, $form_state); $form[$operator] = $form['operator']; - if (isset($form[$operator]['#title'])) { - unset($form[$operator]['#title']); - } - $this->exposedTranslate($form[$operator], 'operator'); unset($form['operator']); @@ -801,11 +799,11 @@ public function buildExposedForm(&$form, &$form_state) { if (!empty($this->options['expose']['identifier'])) { $value = $this->options['expose']['identifier']; $this->valueForm($form, $form_state); - $form[$value] = $form['value']; - - if (isset($form[$value]['#title']) && !empty($form[$value]['#type']) && $form[$value]['#type'] != 'checkbox') { - unset($form[$value]['#title']); + // If no title was specified, prevent validation errors. + if (!isset($form['value']['#title']) || trim($form['value']['#title']) == '') { + $form['value']['#property_validate']['#title'] = array(); } + $form[$value] = $form['value']; $this->exposedTranslate($form[$value], 'value'); diff --git a/core/modules/views/tests/modules/views_test_data/views_test_data.views_execution.inc b/core/modules/views/tests/modules/views_test_data/views_test_data.views_execution.inc index e5a4277..701624b 100644 --- a/core/modules/views/tests/modules/views_test_data/views_test_data.views_execution.inc +++ b/core/modules/views/tests/modules/views_test_data/views_test_data.views_execution.inc @@ -18,7 +18,7 @@ function views_test_data_views_query_substitutions(ViewExecutable $view) { /** * Implements hook_views_form_substitutions(). */ -function views_test_data_views_form_substitutions(ViewExecutable $view) { +function views_test_data_views_form_substitutions() { Drupal::state()->set('views_hook_test_views_form_substitutions', TRUE); } diff --git a/core/modules/views_ui/lib/Drupal/views_ui/Form/Ajax/Rearrange.php b/core/modules/views_ui/lib/Drupal/views_ui/Form/Ajax/Rearrange.php index c8d8a94..c43d17c 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/Form/Ajax/Rearrange.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/Form/Ajax/Rearrange.php @@ -101,6 +101,7 @@ public function buildForm(array $form, array &$form_state) { ); } else { + $name = $id; $form['fields'][$id]['name'] = array('#markup' => t('Broken field @id', array('@id' => $id))); } @@ -108,10 +109,14 @@ public function buildForm(array $form, array &$form_state) { '#type' => 'textfield', '#default_value' => ++$count, '#attributes' => array('class' => array('weight')), + '#title_display' => 'invisible', + '#title' => t('Weight for @title', array('@title' => $name)), ); $form['fields'][$id]['removed'] = array( '#type' => 'checkbox', + '#title' => t('Remove @title', array('@title' => $name)), + '#title_display' => 'invisible', '#id' => 'views-removed-' . $id, '#attributes' => array('class' => array('views-remove-checkbox')), '#default_value' => 0, @@ -119,11 +124,6 @@ public function buildForm(array $form, array &$form_state) { ); } - $name = NULL; - if (isset($form_state['update_name'])) { - $name = $form_state['update_name']; - } - $view->getStandardButtons($form, $form_state, 'views_ui_rearrange_form'); return $form; diff --git a/core/modules/views_ui/lib/Drupal/views_ui/ViewAddFormController.php b/core/modules/views_ui/lib/Drupal/views_ui/ViewAddFormController.php index 7331dab..97c7ef6 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/ViewAddFormController.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/ViewAddFormController.php @@ -91,7 +91,6 @@ public function form(array $form, array &$form_state) { ); $form['name']['id'] = array( '#type' => 'machine_name', - '#title' => t('Machine name'), '#maxlength' => 128, '#machine_name' => array( 'exists' => 'views_get_view',