You are here

public function MeetingResultForm::buildForm in Opigno Moxtra 3.x

Same name and namespace in other branches
  1. 8 src/Form/MeetingResultForm.php \Drupal\opigno_moxtra\Form\MeetingResultForm::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 EntityForm::buildForm

File

src/Form/MeetingResultForm.php, line 23

Class

MeetingResultForm
Provides a form for creating/editing a opigno_moxtra_meeting_result entity.

Namespace

Drupal\opigno_moxtra\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form = parent::buildForm($form, $form_state);

  /** @var \Drupal\opigno_moxtra\MeetingResultInterface $entity */
  $entity = $this->entity;
  $form['meeting'] = [
    '#type' => 'entity_autocomplete',
    '#target_type' => 'opigno_moxtra_meeting',
    '#title' => $this
      ->t('Meeting'),
    '#default_value' => $entity
      ->getMeeting(),
    '#required' => TRUE,
  ];
  $form['user_id'] = [
    '#type' => 'entity_autocomplete',
    '#title' => $this
      ->t('User'),
    '#target_type' => 'user',
    '#default_value' => $entity
      ->getUser(),
    '#required' => TRUE,
  ];
  $form['status'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Status'),
    '#options' => [
      0 => $this
        ->t('Absent'),
      1 => $this
        ->t('Attended'),
    ],
    '#default_value' => $entity
      ->getStatus(),
  ];
  $form['score'] = [
    '#type' => 'number',
    '#title' => $this
      ->t('Score'),
    '#min' => 0,
    '#max' => 100,
    '#step' => 1,
    '#default_value' => $entity
      ->getScore(),
  ];
  return $form;
}