You are here

public function MessageActionForm::buildForm in RNG - Events and Registrations 8

Same name and namespace in other branches
  1. 8.2 src/Form/MessageActionForm.php \Drupal\rng\Form\MessageActionForm::buildForm()
  2. 3.x src/Form/MessageActionForm.php \Drupal\rng\Form\MessageActionForm::buildForm()

Form constructor.

Parameters

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

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

Return value

array The form structure.

Overrides FormInterface::buildForm

File

src/Form/MessageActionForm.php, line 77

Class

MessageActionForm
Creates a rule with a rng_courier_message action.

Namespace

Drupal\rng\Form

Code

public function buildForm(array $form, FormStateInterface $form_state, EntityInterface $rng_event = NULL) {
  $event = clone $rng_event;
  $this->actionPlugin
    ->setConfiguration([
    'active' => FALSE,
  ]);
  $form_state
    ->set('event', $event);
  $triggers = array(
    'rng:custom:date' => $this
      ->t('To all registrations, on a date.'),
    (string) $this
      ->t('Registrations') => array(
      'entity:registration:new' => $this
        ->t('To a single registration, when it is created.'),
      'entity:registration:update' => $this
        ->t('To a single registration, when it is updated.'),
    ),
  );
  $form['trigger'] = array(
    '#type' => 'select',
    '#title' => $this
      ->t('Trigger'),
    '#description' => $this
      ->t('When should this message be sent?'),
    '#options' => $triggers,
    '#default_value' => 'now',
  );
  $form['actions'] = array(
    '#type' => 'actions',
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Create message'),
  );
  $form['actions']['cancel'] = array(
    '#type' => 'link',
    '#title' => $this
      ->t('Cancel'),
    '#url' => Url::fromRoute('rng.event.' . $event
      ->getEntityTypeId() . '.messages', array(
      $event
        ->getEntityTypeId() => $event
        ->id(),
    )),
  );
  return $form;
}