function AddEventFormTrait::entityBundleBuilder

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.

1 call to AddEventFormTrait::entityBundleBuilder()
AddEventForm::submitForm in src/Form/AddEventForm.php
Form submission handler.

File

src/Form/AddEventFormTrait.php, line 144

Class

AddEventFormTrait
Trait for adding an event.

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);
    }
}