You are here

public function EntityReferenceActionsHandler::buildSettingsForm in Entity reference actions 1.x

Build the settings form.

Parameters

array $form: The form array.

\Drupal\Core\Form\FormStateInterface $form_state: The form state object.

string $field_name: The field name.

File

src/EntityReferenceActionsHandler.php, line 396

Class

EntityReferenceActionsHandler
Provides the form functions to call actions on referenced entities.

Namespace

Drupal\entity_reference_actions

Code

public function buildSettingsForm(array &$form, FormStateInterface $form_state, $field_name) {
  $form['enabled'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Enable Entity Reference Actions'),
    '#default_value' => $this->settings['enabled'],
  ];
  $form['options'] = [
    '#type' => 'fieldset',
    '#title' => $this
      ->t('Entity Reference Actions settings'),
    '#states' => [
      'visible' => [
        ':input[name="fields[' . $field_name . '][settings_edit_form][third_party_settings][entity_reference_actions][enabled]"]' => [
          'checked' => TRUE,
        ],
      ],
    ],
  ];
  $form['options']['action_title'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Action title'),
    '#default_value' => $this->settings['options']['action_title'],
    '#description' => $this
      ->t('The title shown above the actions dropdown.'),
  ];
  $form['options']['include_exclude'] = [
    '#type' => 'radios',
    '#title' => $this
      ->t('Available actions'),
    '#options' => [
      'exclude' => $this
        ->t('All actions, except selected'),
      'include' => $this
        ->t('Only selected actions'),
    ],
    '#default_value' => $this->settings['options']['include_exclude'],
  ];
  $form['options']['selected_actions'] = [
    '#type' => 'checkboxes',
    '#title' => $this
      ->t('Selected actions'),
    '#options' => $this
      ->getBulkOptions(FALSE),
    '#default_value' => $this->settings['options']['selected_actions'],
  ];
}