diff --git a/core/modules/block/lib/Drupal/block/Tests/Views/DisplayBlockTest.php b/core/modules/block/lib/Drupal/block/Tests/Views/DisplayBlockTest.php index eda9285..97d0c54 100644 --- a/core/modules/block/lib/Drupal/block/Tests/Views/DisplayBlockTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/Views/DisplayBlockTest.php @@ -221,6 +221,16 @@ public function testViewsBlockForm() { $config = $block->getPlugin()->getConfiguration(); $this->assertEqual(5, $config['items_per_page'], "'Items per page' is properly saved."); + + // Tests the override of the label capability. + $edit = array(); + $edit['settings[views_label_checkbox]'] = 1; + $edit['settings[views_label]'] = 'Custom title'; + $this->drupalPostForm('admin/structure/block/add/views_block:test_view_block-block_1/' . $default_theme, $edit, t('Save block')); + + $block = $storage->load('views_block__test_view_block_block_1_5'); + $config = $block->getPlugin()->getConfiguration(); + $this->assertEqual('Custom title', $config['views_label'], "'Label' is properly saved."); } /** diff --git a/core/modules/views/lib/Drupal/views/Plugin/Block/ViewsBlock.php b/core/modules/views/lib/Drupal/views/Plugin/Block/ViewsBlock.php index 9628826..1df1768 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/Block/ViewsBlock.php +++ b/core/modules/views/lib/Drupal/views/Plugin/Block/ViewsBlock.php @@ -79,6 +79,7 @@ public function blockValidate($form, &$form_state) { * {@inheritdoc} */ public function blockSubmit($form, &$form_state) { + parent::blockSubmit($form, $form_state); if ($this->displaySet) { $this->view->display_handler->blockSubmit($this, $form, $form_state); } 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 7e47d78..106da28 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/Block/ViewsBlockBase.php +++ b/core/modules/views/lib/Drupal/views/Plugin/Block/ViewsBlockBase.php @@ -106,9 +106,9 @@ public function buildConfigurationForm(array $form, array &$form_state) { // 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; + $form['#pre_render'][] = '\Drupal\views\Plugin\views\PluginBase::preRenderAddFieldsetMarkup'; // Allow to override the label on the actual page. $form['views_label_checkbox'] = array( @@ -128,7 +128,7 @@ public function buildConfigurationForm(array $form, array &$form_state) { ), ); - $form['views_label_fieldset']['views_label_warning'] = array( + $form['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( @@ -138,9 +138,10 @@ public function buildConfigurationForm(array $form, array &$form_state) { ), ), ), + '#fieldset' => 'views_label_fieldset', ); - $form['views_label_fieldset']['views_label'] = array( + $form['views_label'] = array( '#title' => $this->t('Title'), '#type' => 'textfield', '#default_value' => $this->configuration['views_label'] ?: $this->view->getTitle(), @@ -151,6 +152,7 @@ public function buildConfigurationForm(array $form, array &$form_state) { ), ), ), + '#fieldset' => 'views_label_fieldset', ); @@ -163,7 +165,7 @@ public function buildConfigurationForm(array $form, array &$form_state) { */ public function blockSubmit($form, &$form_state) { if (!empty($form_state['values']['views_label_checkbox'])) { - $this->configuration['views_label'] = $form_state['values']['label']; + $this->configuration['views_label'] = $form_state['values']['views_label']; } else { $this->configuration['views_label'] = '';