public function EntityReferenceSynonymsAutocomplete::settingsForm in Synonyms 2.0.x
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
- modules/
synonyms_autocomplete/ src/ Plugin/ Field/ FieldWidget/ EntityReferenceSynonymsAutocomplete.php, line 38
Class
- EntityReferenceSynonymsAutocomplete
- Plugin implementation of the 'synonyms friendly autocomplete' widget.
Namespace
Drupal\synonyms_autocomplete\Plugin\Field\FieldWidgetCode
public function settingsForm(array $form, FormStateInterface $form_state) {
$elements = parent::settingsForm($form, $form_state);
$elements['suggestion_size'] = [
'#type' => 'textfield',
'#title' => $this
->t('Suggestions Size'),
'#description' => $this
->t('Please, enter how many suggested entities to show in the autocomplete textfield.'),
'#required' => TRUE,
'#default_value' => $this
->getSetting('suggestion_size'),
];
$elements['suggest_only_unique'] = [
'#type' => 'checkbox',
'#title' => t('Suggest only one entry per entity'),
'#description' => t('If you want to include only name or a single synonym, suggesting a particular entity, while disregarding all ongoing ones, please, tick this checkbox on.'),
'#default_value' => $this
->getSetting('suggest_only_unique'),
];
$elements['match'] = [
'#type' => 'radios',
'#title' => $this
->t('Match operator'),
'#description' => $this
->t('Choose how to match the keyword against existing data.'),
'#options' => $this
->getMatchOperatorOptions(),
'#default_value' => $this
->getSetting('match'),
'#required' => TRUE,
];
return $elements;
}