You are here

public function CreateActivityForm::buildForm in Activity 8

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 MultiStepFormBase::buildForm

File

src/Form/CreateActivityForm.php, line 52

Class

CreateActivityForm
Create activities form.

Namespace

Drupal\activity\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {

  // Events - when to trigger actions.
  $options = [
    'comment_insert' => t('Save new comment'),
    'comment_update' => t('Update comment'),
    'comment_delete' => t('Delete comment'),
    'node_insert' => t('Save new node'),
    'node_update' => t('Update node'),
    'node_delete' => t('Delete node'),
    'user_insert' => t('Save new user'),
    'user_update' => t('Update user'),
    'user_delete' => t('Delete user'),
  ];
  $form = parent::buildForm($form, $form_state);

  // Event name.
  $form['activity_label'] = [
    '#type' => 'textfield',
    '#title' => t('Label'),
    '#default_value' => '',
    '#required' => TRUE,
    '#size' => 30,
    '#attributes' => [
      'class' => [
        'activity_label',
      ],
    ],
  ];
  $form['activity_actions'] = [
    '#type' => 'radios',
    '#title' => $this
      ->t('Choose your hook'),
    '#required' => TRUE,
    '#default_value' => 1,
    '#options' => $options,
  ];
  $form['submit'] = [
    '#type' => 'submit',
    '#value' => t('Create'),
  ];
  return $form;
}