public function ViewsBlockBase::buildConfigurationForm in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/views/src/Plugin/Block/ViewsBlockBase.php \Drupal\views\Plugin\Block\ViewsBlockBase::buildConfigurationForm()
Creates a generic configuration form for all block types. Individual block plugins can add elements to this form by overriding BlockBase::blockForm(). Most block plugins should not override this method unless they need to alter the generic form elements.
Overrides BlockBase::buildConfigurationForm
See also
\Drupal\Core\Block\BlockBase::blockForm()
File
- core/
modules/ views/ src/ Plugin/ Block/ ViewsBlockBase.php, line 116 - Contains \Drupal\views\Plugin\Block\ViewsBlockBase.
Class
- ViewsBlockBase
- Base class for Views block plugins.
Namespace
Drupal\views\Plugin\BlockCode
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form = parent::buildConfigurationForm($form, $form_state);
// Set the default label to '' so the views internal title is used.
$form['label']['#default_value'] = '';
$form['label']['#access'] = FALSE;
// Unset the machine_name provided by BlockForm.
unset($form['id']['#machine_name']['source']);
// 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(
'#type' => 'checkbox',
'#title' => $this
->t('Override title'),
'#default_value' => !empty($this->configuration['views_label']),
);
$form['views_label_fieldset'] = array(
'#type' => 'fieldset',
'#states' => array(
'visible' => array(
array(
':input[name="settings[views_label_checkbox]"]' => array(
'checked' => TRUE,
),
),
),
),
);
$form['views_label'] = array(
'#title' => $this
->t('Title'),
'#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,
),
),
),
),
'#fieldset' => 'views_label_fieldset',
);
if ($this->view->storage
->access('edit') && \Drupal::moduleHandler()
->moduleExists('views_ui')) {
$form['views_label']['#description'] = $this
->t('Changing the title here means it cannot be dynamically altered anymore. (Try changing it directly in <a href=":url">@name</a>.)', array(
':url' => \Drupal::url('entity.view.edit_display_form', array(
'view' => $this->view->storage
->id(),
'display_id' => $this->displayID,
)),
'@name' => $this->view->storage
->label(),
));
}
else {
$form['views_label']['#description'] = $this
->t('Changing the title here means it cannot be dynamically altered anymore.');
}
return $form;
}