You are here

public function MarkupItem::fieldSettingsForm in Markup 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 FieldItemBase::fieldSettingsForm

File

src/Plugin/Field/FieldType/MarkupItem.php, line 63

Class

MarkupItem
Plugin implementation of the 'markup' field type.

Namespace

Drupal\markup\Plugin\Field\FieldType

Code

public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
  $settings = $this
    ->getSettings();
  $element['markup'] = [
    '#type' => 'text_format',
    '#title' => $this
      ->t('Markup'),
    '#default_value' => isset($settings['markup']['value']) ? $settings['markup']['value'] : '',
    '#format' => !empty($settings['markup']['format']) ? $settings['markup']['format'] : filter_default_format(),
    '#required' => TRUE,
    '#rows' => 15,
    '#description' => $this
      ->t('The markup to be displayed. Any HTML is legal here, so be careful not to break your page layout.'),
  ];
  $element['instructions'] = [
    '#markup' => htmlentities($this
      ->t('This is a special field. It will output the markup below, on the node/edit form for this content type. Consider wrapping any visible output in <div class="form-item"></div> to follow form standards.')),
    '#weight' => -1,
  ];
  return $element;
}