diff --git a/core/modules/block/lib/Drupal/block/Annotation/Block.php b/core/modules/block/lib/Drupal/block/Annotation/Block.php index 62541ab..64987e6 100644 --- a/core/modules/block/lib/Drupal/block/Annotation/Block.php +++ b/core/modules/block/lib/Drupal/block/Annotation/Block.php @@ -30,6 +30,6 @@ class Block extends Plugin { * * @ingroup plugin_translatable */ - public $admin_label; + public $admin_label = ''; } diff --git a/core/modules/block/lib/Drupal/block/Entity/Block.php b/core/modules/block/lib/Drupal/block/Entity/Block.php index a8ea16e..0298f44 100644 --- a/core/modules/block/lib/Drupal/block/Entity/Block.php +++ b/core/modules/block/lib/Drupal/block/Entity/Block.php @@ -122,9 +122,6 @@ public function getPlugin() { public function label($langcode = NULL) { $settings = $this->get('settings'); $definition = $this->getPlugin()->getPluginDefinition(); - $definition += array( - 'admin_label' => '', - ); return $settings['label'] ?: $definition['admin_label']; } diff --git a/core/modules/views/lib/Drupal/views/Plugin/Block/ViewsBlockBase.php b/core/modules/views/lib/Drupal/views/Plugin/Block/ViewsBlockBase.php index a04fd08..431e31a 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/Block/ViewsBlockBase.php +++ b/core/modules/views/lib/Drupal/views/Plugin/Block/ViewsBlockBase.php @@ -104,6 +104,12 @@ public function buildConfigurationForm(array $form, array &$form_state) { $form['label']['#default_value'] = ''; $form['label']['#access'] = FALSE; + // Unset the machine_name provided by BlockFormController. + unset($form['id']['#machine_name']['source']); + // Load the Views plugin object using form_state array and create a + // Prevent users from changing the auto-generated block machine_name. + $form['id']['#access'] = FALSE; + // Allow to override the label on the actual page. $form['views_label_checkbox'] = array( '#type' => 'checkbox', @@ -114,20 +120,24 @@ public function buildConfigurationForm(array $form, array &$form_state) { $form['views_label_fieldset'] = array( '#type' => 'fieldset', '#states' => array( - 'visible' => array(array( - ':input[name="settings[views_label_checkbox]"]' => array('checked' => TRUE), + 'visible' => array( + array( + ':input[name="settings[views_label_checkbox]"]' => array('checked' => TRUE), + ), ), - )), + ), ); $form['views_label_fieldset']['views_label_warning'] = array( '#markup' => $this->t('
In most cases you better change the title directly on the view. Overriding the title here will remove dynamic title support from arguments for example.
'), '#type' => 'item', '#states' => array( - 'visible' => array(array( - ':input[name="settings[views_label_checkbox]"]' => array('checked' => TRUE), + 'visible' => array( + array( + ':input[name="settings[views_label_checkbox]"]' => array('checked' => TRUE), + ), ), - )), + ), ); $form['views_label_fieldset']['views_label'] = array( @@ -135,17 +145,21 @@ public function buildConfigurationForm(array $form, array &$form_state) { '#type' => 'textfield', '#default_value' => $this->configuration['views_label'] ?: $this->view->getTitle(), '#states' => array( - 'visible' => array(array( - ':input[name="settings[views_label_checkbox]"]' => array('checked' => TRUE), + 'visible' => array( + array( + ':input[name="settings[views_label_checkbox]"]' => array('checked' => TRUE), + ), ), - )), + ), ); + + return $form; } /** - * {@inheritdoc}{ + * {@inheritdoc} */ public function blockSubmit($form, &$form_state) { if (!empty($form_state['values']['views_label_checkbox'])) { diff --git a/core/modules/views/views.module b/core/modules/views/views.module index f71c966..8445804 100644 --- a/core/modules/views/views.module +++ b/core/modules/views/views.module @@ -1355,23 +1355,3 @@ function views_element_validate_tags($element, &$form_state) { } } } - - -/** - * Implements hook_form_FORM_ID_alter for block_form(). - * - * Views overrides block configuration form elements during - * \Drupal\views\Plugin\Block\ViewsBlock::form() but machine_name assignment is - * added later by \Drupal\block\BlockFormController::form() so we provide an - * override for the block machine_name here. - */ -function views_form_block_form_alter(&$form, &$form_state) { - // Ensure the block-form being altered is a Views block configuration form. - if ($form['settings']['module']['#value'] == 'views') { - // Unset the machine_name provided by BlockFormController. - unset($form['id']['#machine_name']['source']); - // Load the Views plugin object using form_state array and create a - // Prevent users from changing the auto-generated block machine_name. - $form['id']['#access'] = FALSE; - } -}