public function LoopThroughFieldVariable::getSettingsForm in Business Rules 8
Same name and namespace in other branches
- 2.x src/Plugin/BusinessRulesAction/LoopThroughFieldVariable.php \Drupal\business_rules\Plugin\BusinessRulesAction\LoopThroughFieldVariable::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/ LoopThroughFieldVariable.php, line 63
Class
- LoopThroughFieldVariable
- Class LoopThroughFieldVariable.
Namespace
Drupal\business_rules\Plugin\BusinessRulesActionCode
public function getSettingsForm(array &$form, FormStateInterface $form_state, ItemInterface $item) {
$variables = Variable::loadMultipleByType('entity_filed_variable');
$options = [];
/** @var \Drupal\business_rules\Entity\Variable $variable */
foreach ($variables as $variable) {
$options[$variable
->id()] = $variable
->label();
}
arsort($options);
$settings['variable'] = [
'#type' => 'select',
'#title' => t('Select entity field variable variable'),
'#options' => $options,
'#default_value' => $item
->getSettings('variable'),
'#required' => TRUE,
];
if (!$item
->isNew()) {
// The items to be executed.
$settings['items'] = [
'#type' => 'details',
'#title' => t('Items to execute during the loop'),
'#open' => TRUE,
];
$settings['items'][] = $this
->formItems($form, $form_state, $item);
}
return $settings;
}