public function ConditionForm::form in Business Rules 8
Same name and namespace in other branches
- 2.x src/Form/ConditionForm.php \Drupal\business_rules\Form\ConditionForm::form()
Gets the actual form array to be built.
Overrides ItemForm::form
See also
\Drupal\Core\Entity\EntityForm::processForm()
\Drupal\Core\Entity\EntityForm::afterBuild()
File
- src/
Form/ ConditionForm.php, line 38
Class
- ConditionForm
- Class ConditionForm.
Namespace
Drupal\business_rules\FormCode
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
if (!$this->entity
->isNew()) {
$form['reverse'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Reverse value'),
'#description' => $this
->t("It's equivalent to (NOT) operator. Invert the condition result from TRUE to FALSE and from FALSE to TRUE."),
'#default_value' => $this->entity
->isReverse(),
'#weight' => 31,
];
// Do not show success/fail items if it is part of a condition set.
if (!$this
->isPartOfConditionSet($this->entity)) {
$form['additional_fields']['success'] = [
'#type' => 'details',
'#title' => $this
->t('Items to execute if condition succeed'),
'#open' => TRUE,
'#attributes' => [
'class' => [
'success',
],
],
];
$form['additional_fields']['success']['items'] = $this
->formItems($form, $form_state, 'success');
$form['additional_fields']['fail'] = [
'#type' => 'details',
'#title' => $this
->t('Items to execute if condition fails'),
'#open' => TRUE,
'#attributes' => [
'class' => [
'fail',
],
],
];
$form['additional_fields']['fail']['items'] = $this
->formItems($form, $form_state, 'fail');
$form['#attached']['library'][] = 'business_rules/style';
}
else {
$form['no_items'] = [
'#type' => 'details',
'#title' => $this
->t('No items available'),
'#description' => $this
->t('As this condition is part of a condition set (AND|OR), you can not add success/fail items here. Use the condition set instead.'),
'#open' => TRUE,
'#weight' => 900,
];
unset($form['flowchart']);
}
}
return $form;
}