Example #1
0
 /**
  * {@inheritdoc}
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     $form['action_table'] = ['#type' => 'container'];
     $form['action_table']['table'] = ['#theme' => 'table', '#caption' => $this->t('Actions'), '#header' => [$this->t('Elements'), $this->t('Operations')], '#empty' => t('None')];
     foreach ($this->actionSet as $uuid => $action) {
         $form['action_table']['table']['#rows'][] = ['element' => $action->getLabel(), 'operations' => ['data' => ['#type' => 'dropbutton', '#links' => ['edit' => ['title' => $this->t('Edit'), 'url' => Url::fromRoute('rules.reaction_rule.expression.edit', ['reaction_config' => $this->actionSet->getRoot()->getConfigEntityId(), 'uuid' => $uuid])], 'delete' => ['title' => $this->t('Delete'), 'url' => Url::fromRoute('rules.reaction_rule.expression.delete', ['rules_reaction_rule' => $this->actionSet->getRoot()->getConfigEntityId(), 'uuid' => $uuid])]]]]];
     }
     // @todo Put this into the table as last row and style it like it was in
     // Drupal 7 Rules.
     $form['add_action'] = ['#theme' => 'menu_local_action', '#link' => ['title' => $this->t('Add action'), 'url' => Url::fromRoute('rules.reaction_rule.expression.add', ['reaction_config' => $this->actionSet->getRoot()->getConfigEntityId(), 'expression_id' => 'rules_action'])]];
     return $form;
 }