You are here

public function ReactionRuleAddForm::entityBundleBuilder in Rules 8.3

Callback method for the #entity_builder form property.

Used to qualify the selected event name with a bundle suffix.

Parameters

string $entity_type: The type of the entity.

\Drupal\Core\Config\Entity\ConfigEntityInterface $entity: The entity whose form is being built.

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

File

src/Form/ReactionRuleAddForm.php, line 176

Class

ReactionRuleAddForm
Provides a form to add a reaction rule.

Namespace

Drupal\rules\Form

Code

public function entityBundleBuilder($entity_type, ConfigEntityInterface $entity, array $form, FormStateInterface $form_state) {
  $bundle = $form_state
    ->getValue('bundle');
  if (!empty($bundle) && $bundle != 'notselected') {
    $event_name = $form_state
      ->getValue([
      'events',
      0,
      'event_name',
    ]);

    // Fully-qualify the event name if a bundle was selected.
    $form_state
      ->setValue([
      'events',
      0,
      'event_name',
    ], $event_name . '--' . $bundle);
  }
}