public function LinkIconItem::fieldSettingsForm in Link Icon 8
Returns a form for the field-level settings.
Invoked from \Drupal\field_ui\Form\FieldConfigEditForm to allow administrators to configure field-level settings.
Parameters
array $form: The form where the settings form is being included in.
\Drupal\Core\Form\FormStateInterface $form_state: The form state of the (entire) configuration form.
Return value
array The form definition for the field settings.
Overrides LinkItem::fieldSettingsForm
File
- src/
LinkIconItem.php, line 27
Class
- LinkIconItem
- Modify plugin implementation of the 'link' field settings form.
Namespace
Drupal\linkiconCode
public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
$element = parent::fieldSettingsForm($form, $form_state);
// Appends our option to the title.
$element['title']['#options'] += [
LinkIconManagerInterface::LINKICON_PREDEFINED => $this
->t('Predefined'),
];
$element['title_predefined'] = [
'#type' => 'textarea',
'#title' => $this
->t('Allowed link texts'),
'#default_value' => $this
->getSetting('title_predefined'),
'#description' => '<p>' . $this
->t("Enter the list of key|value pairs of predefined link texts separated by new line, where key is the icon name without prefix, e.g.: <br />for <em>icon-facebook</em>, place <em>facebook|Facebook</em>. The prefix is defined at Display formatter so that you are not stuck in database when the icon vendor change prefixes from 'icon-' to just 'fa-', etc. Make sure the icon name is available at your icon set. To have a tooltip different from the title, add a third pipe value. <br />Token relevant to this entity is supported, e.g.: <strong>facebook|Facebook|[node:title]</strong> or <strong>facebook|Facebook|[user:name]'s Facebook page</strong>.<br /><strong>Warning!</strong> Pre-existing values will be reset.") . '<br><br></p>',
'#states' => [
'visible' => [
':input[name="settings[title]"]' => [
'value' => LinkIconManagerInterface::LINKICON_PREDEFINED,
],
],
],
];
return $element;
}