You are here

public function RadioactivityReferenceItem::fieldSettingsForm in Radioactivity 4.0.x

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 EntityReferenceItem::fieldSettingsForm

File

src/Plugin/Field/FieldType/RadioactivityReferenceItem.php, line 144

Class

RadioactivityReferenceItem
Plugin implementation of the Radioactivity Reference field type.

Namespace

Drupal\radioactivity\Plugin\Field\FieldType

Code

public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
  $field = $form_state
    ->getFormObject()
    ->getEntity();
  $form = parent::fieldSettingsForm($form, $form_state);
  $form['handler']['#access'] = FALSE;
  $form['default_energy'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Default energy'),
    '#description' => $this
      ->t('The default energy value for this field, used when creating new content.'),
    '#required' => TRUE,
    '#default_value' => $field
      ->getSetting('default_energy'),
    '#pattern' => '[0-9]+(\\.[0-9]+)?',
    '#size' => 20,
  ];
  return $form;
}