ActionAddForm.php 694 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. namespace Drupal\action;
  3. use Drupal\Core\Form\FormStateInterface;
  4. /**
  5. * Provides a form for action add forms.
  6. *
  7. * @internal
  8. */
  9. class ActionAddForm extends ActionFormBase {
  10. /**
  11. * {@inheritdoc}
  12. *
  13. * @param string $action_id
  14. * The action ID.
  15. */
  16. public function buildForm(array $form, FormStateInterface $form_state, $action_id = NULL) {
  17. $this->entity->setPlugin($action_id);
  18. // Derive the label and type from the action definition.
  19. $definition = $this->entity->getPluginDefinition();
  20. $this->entity->set('label', $definition['label']);
  21. $this->entity->set('type', $definition['type']);
  22. return parent::buildForm($form, $form_state);
  23. }
  24. }