public function EmailContactInlineFormatter::settingsForm in Email Contact 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 FormatterBase::settingsForm
File
- src/
Plugin/ Field/ FieldFormatter/ EmailContactInlineFormatter.php, line 34
Class
- EmailContactInlineFormatter
- Plugin implementation of the 'email_contact_inline' formatter.
Namespace
Drupal\email_contact\Plugin\Field\FieldFormatterCode
public function settingsForm(array $form, FormStateInterface $form_state) {
$element = array();
$element['redirection_to'] = array(
'#title' => t('Redirection after form submit'),
'#type' => 'radios',
'#options' => array(
'front' => t('To the frontpage'),
'current' => t('To the current page'),
'custom' => t('To a custom path'),
),
'#default_value' => $this
->getSetting('redirection_to'),
'#required' => TRUE,
);
$element['custom_path'] = array(
'#title' => t('Redirection path'),
'#type' => 'textfield',
'#states' => array(
'visible' => array(
'input[name="redirection_to"]' => array(
'value' => 'custom',
),
),
),
'#default_value' => $this
->getSetting('custom_path'),
'#element_validate' => [
[
$this,
'validateCustomPath',
],
],
);
$element['include_values'] = array(
'#title' => t('Display all field values in email body'),
'#type' => 'checkbox',
'#default_value' => $this
->getSetting('include_values'),
);
$element['default_message'] = array(
'#title' => t('Additional message in email body'),
'#type' => 'textfield',
'#default_value' => $this
->getSetting('default_message'),
);
$element['link_text'] = array(
'#type' => 'hidden',
'#value' => '',
);
if (\Drupal::moduleHandler()
->moduleExists('token')) {
$element['token_help'] = array(
'#theme' => 'token_tree_link',
'#token_types' => array(
'node',
),
);
}
return $element;
}