public function EntityBlockWidget::settingsForm in Entityblock 8
Returns a form to configure settings for the widget.
Invoked from \Drupal\field_ui\Form\EntityDisplayFormBase to allow administrators to configure the widget. The field_ui module takes care of handling submitted form values.
Parameters
array $form: The form where the settings form is being included in.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form definition for the widget settings.
Overrides WidgetBase::settingsForm
File
- src/
Plugin/ Field/ FieldWidget/ EntityBlockWidget.php, line 41 - Contains \Drupal\entityblock\Plugin\Field\FieldWidget\EntityBlockWidget.
Class
- EntityBlockWidget
- Plugin implementation of the 'EntityBlock' widget.
Namespace
Drupal\entityblock\Plugin\Field\FieldWidgetCode
public function settingsForm(array $form, FormStateInterface $form_state) {
$elements = parent::settingsForm($form, $form_state);
$elements['view_modes'] = array(
'#type' => 'select',
'#title' => $this
->t('View modes'),
'#default_value' => $this
->getSetting('view_modes'),
'#description' => $this
->t('View modes that are available to the user to choose from, when you select only 1 option then the user is not able to make a selection.'),
'#required' => TRUE,
'#options' => $this
->getViewModes(),
'#multiple' => TRUE,
);
$elements['force_enabled'] = array(
'#type' => 'checkbox',
'#title' => $this
->t('Force "Display as block"'),
'#description' => $this
->t('Do not provide the user a "Display as block" checkbox. You do not want to set this checkbox if you provide a multi value field because the user cannot remove blocks then.'),
'#default_value' => $this
->getSetting('force_enabled'),
);
$elements['force_title'] = array(
'#type' => 'checkbox',
'#title' => $this
->t('Force "Block title"'),
'#description' => $this
->t('Do not provide the user a "Block title" textfield.'),
'#default_value' => $this
->getSetting('force_title'),
);
return $elements;
}