public function PatternWrapperEntityReferenceFormatter::settingsForm in UI Patterns Field Formatters 8
Returns a form to configure settings for the formatter.
Invoked from \Drupal\field_ui\Form\EntityDisplayFormBase to allow administrators to configure the formatter. 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 elements for the formatter settings.
Overrides EntityReferenceEntityFormatter::settingsForm
File
- src/
Plugin/ Field/ FieldFormatter/ PatternWrapperEntityReferenceFormatter.php, line 129
Class
- PatternWrapperEntityReferenceFormatter
- Plugin implementation of 'pattern_wrapper_entity_reference_formatter'.
Namespace
Drupal\ui_patterns_field_formatters\Plugin\Field\FieldFormatterCode
public function settingsForm(array $form, FormStateInterface $form_state) {
$form = parent::settingsForm($form, $form_state);
$field_storage_definition = $this->fieldDefinition
->getFieldStorageDefinition();
$context = [
'storageDefinition' => $field_storage_definition,
'limit' => $field_storage_definition
->getPropertyNames(),
];
// Some modifications to make 'variant' default value working.
$configuration = $this
->getSettings();
$pattern = $this
->getSetting('pattern');
$pattern_variant = $this
->getCurrentVariant($pattern);
if (isset($pattern_variant)) {
$configuration['pattern_variant'] = $pattern_variant;
}
$this
->buildPatternDisplayForm($form, 'field_wrapper', $context, $configuration);
return $form;
}