You are here

public function InviteByEmailBlockForm::buildForm in Invite 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 FormInterface::buildForm

File

modules/invite_by_email/src/Form/InviteByEmailBlockForm.php, line 26

Class

InviteByEmailBlockForm
Class InviteByEmailBlockForm.

Namespace

Drupal\invite_by_email\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $invite_type = $this
    ->config('invite.invite_type.' . $form_state
    ->getBuildInfo()['args'][0]);
  $data = unserialize($invite_type
    ->get('data'));
  $form['email'] = [
    '#type' => 'email',
    '#required' => TRUE,
    '#title' => $this
      ->t('Email'),
  ];
  if (!$data['use_default'] && $data['subject_editable']) {
    $invite_email_subject_default = \Drupal::service('entity_field.manager')
      ->getFieldDefinitions('invite', 'invite')['field_invite_email_subject']
      ->getDefaultValueLiteral()[0]['value'];
    $form['email_subject'] = [
      '#type' => 'textfield',
      '#required' => TRUE,
      '#title' => $this
        ->t('Email subject'),
      '#default_value' => $invite_email_subject_default,
    ];
  }
  $form['send_invitation'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Send Invitation'),
  ];
  return $form;
}