diff --git a/core/modules/action/config/schema/views.field.schema.yml b/core/modules/action/config/schema/views.field.schema.yml new file mode 100644 index 0000000000000000000000000000000000000000..cd19eee3679ada0681673f737ca4b8f07ae5282d --- /dev/null +++ b/core/modules/action/config/schema/views.field.schema.yml @@ -0,0 +1,7 @@ +views.field.bulk_form: + type: views_field + label: 'Bulk form' + mapping: + action_title: + type: label + label: 'Action title' diff --git a/core/modules/action/lib/Drupal/action/Tests/BulkFormTest.php b/core/modules/action/lib/Drupal/action/Tests/BulkFormTest.php index 86edb19939395173cc18377c84a6abad0eae9861..dcce0c72bec232b23695eb06fc0f010ae6aa76d8 100644 --- a/core/modules/action/lib/Drupal/action/Tests/BulkFormTest.php +++ b/core/modules/action/lib/Drupal/action/Tests/BulkFormTest.php @@ -113,6 +113,21 @@ public function testBulkForm() { $this->drupalGet('test_bulk_form'); $this->assertNoOption('edit-action', 'node_make_sticky_action'); $this->assertNoOption('edit-action', 'node_make_unsticky_action'); + + // Check the default title. + $this->drupalGet('test_bulk_form'); + $result = $this->xpath('//label[@for="edit-action"]'); + $this->assertEqual('With selection', (string) $result[0]); + + // Setup up a different bulk form title. + $view = views_get_view('test_bulk_form'); + $display = &$view->storage->getDisplay('default'); + $display['display_options']['fields']['action_bulk_form']['action_title'] = 'Test title'; + $view->save(); + + $this->drupalGet('test_bulk_form'); + $result = $this->xpath('//label[@for="edit-action"]'); + $this->assertEqual('Test title', (string) $result[0]); } } diff --git a/core/modules/system/lib/Drupal/system/Plugin/views/field/BulkFormBase.php b/core/modules/system/lib/Drupal/system/Plugin/views/field/BulkFormBase.php index 1f53f9fc6e1f31b612f6892c3ea56a1944f558e2..a14e0599f6d8210acb95a9d40c83ff47c71ebaa7 100644 --- a/core/modules/system/lib/Drupal/system/Plugin/views/field/BulkFormBase.php +++ b/core/modules/system/lib/Drupal/system/Plugin/views/field/BulkFormBase.php @@ -25,6 +25,30 @@ abstract class BulkFormBase extends FieldPluginBase { */ protected $actions = array(); + /** + * {@inheritdoc } + */ + protected function defineOptions() { + $options = parent::defineOptions(); + $options['action_title'] = array('default' => 'With selection', 'translatable' => TRUE); + return $options; + } + + /** + * {@inheritdoc } + */ + public function buildOptionsForm(&$form, &$form_state) { + $form['action_title'] = array( + '#type' => 'textfield', + '#title' => t('Action title'), + '#default_value' => $this->options['action_title'], + '#description' => t('The title shown above the actions dropdown.'), + ); + + parent::buildOptionsForm($form, $form_state); + } + + /** * Constructs a new BulkForm object. * @@ -116,7 +140,7 @@ public function views_form(&$form, &$form_state) { ); $form['header'][$this->options['id']]['action'] = array( '#type' => 'select', - '#title' => t('With selection'), + '#title' => $this->options['action_title'], '#options' => $this->getBulkOptions(), );