public function FileBrowserWidget::settingsForm in Entity Browser 8
Same name and namespace in other branches
- 8.2 src/Plugin/Field/FieldWidget/FileBrowserWidget.php \Drupal\entity_browser\Plugin\Field\FieldWidget\FileBrowserWidget::settingsForm()
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 EntityReferenceBrowserWidget::settingsForm
File
- src/
Plugin/ Field/ FieldWidget/ FileBrowserWidget.php, line 153
Class
- FileBrowserWidget
- Entity browser file widget.
Namespace
Drupal\entity_browser\Plugin\Field\FieldWidgetCode
public function settingsForm(array $form, FormStateInterface $form_state) {
$element = parent::settingsForm($form, $form_state);
$has_file_entity = $this->moduleHandler
->moduleExists('file_entity');
$element['field_widget_display']['#access'] = FALSE;
$element['field_widget_display_settings']['#access'] = FALSE;
$element['view_mode'] = [
'#title' => $this
->t('File view mode'),
'#type' => 'select',
'#default_value' => $this
->getSetting('view_mode'),
'#options' => $this->displayRepository
->getViewModeOptions('file'),
'#access' => $has_file_entity,
];
$element['preview_image_style'] = [
'#title' => $this
->t('Preview image style'),
'#type' => 'select',
'#options' => image_style_options(FALSE),
'#default_value' => $this
->getSetting('preview_image_style'),
'#description' => $this
->t('The preview image will be shown while editing the content. Only relevant if using the default file view mode.'),
'#weight' => 15,
'#access' => !$has_file_entity && $this->fieldDefinition
->getType() == 'image',
];
return $element;
}