You are here

public function FetchEntityVariableAction::getSettingsForm in Business Rules 8

Same name and namespace in other branches
  1. 2.x src/Plugin/BusinessRulesAction/FetchEntityVariableAction.php \Drupal\business_rules\Plugin\BusinessRulesAction\FetchEntityVariableAction::getSettingsForm()

Return the form array.

@internal param array $form

Parameters

array $form: The form array.

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

\Drupal\business_rules\ItemInterface $item: The configured item.

Return value

array The render array for the settings form.

Overrides BusinessRulesItemPluginBase::getSettingsForm

File

src/Plugin/BusinessRulesAction/FetchEntityVariableAction.php, line 43

Class

FetchEntityVariableAction
Class FetchEntityVariable.

Namespace

Drupal\business_rules\Plugin\BusinessRulesAction

Code

public function getSettingsForm(array &$form, FormStateInterface $form_state, ItemInterface $item) {
  $settings = [];
  if (!$item
    ->isNew()) {
    $settings['empty_variable'] = [
      '#type' => 'select',
      '#title' => t('Empty variable'),
      '#required' => TRUE,
      '#description' => t('Empty variable to be filled in.'),
      '#options' => $this
        ->getAvailableEmptyVariables($item),
      '#default_value' => empty($item
        ->getSettings('empty_variable')) ? '' : $item
        ->getSettings('empty_variable'),
    ];
    $settings['value'] = [
      '#type' => 'textfield',
      '#title' => t('Value'),
      '#default_value' => $item
        ->getSettings('value'),
      '#description' => t('The entity ID value to fill the variable.'),
    ];
  }
  return $settings;
}