public function LocalTaskAssignForm::buildForm

File

translators/tmgmt_local/src/Form/LocalTaskAssignForm.php, line 19

Class

LocalTaskAssignForm
Assign task confirmation form.

Namespace

Drupal\tmgmt_local\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  parent::buildForm($form, $form_state);
  $roles = tmgmt_local_translator_roles();
  if (empty($roles)) {
    $this
      ->messenger()
      ->addWarning(t('No user role has the "provide translation services" permission. <a href="@url">Configure permissions</a> for the Drupal user module.', array(
      '@url' => URL::fromRoute('user.admin_permissions'),
    )));
  }
  $form['tuid'] = array(
    '#title' => t('Assign to'),
    '#type' => 'select',
    '#empty_option' => t('- Select user -'),
    '#options' => tmgmt_local_get_assignees_for_tasks([
      $this
        ->getEntity()
        ->id(),
    ]),
    '#required' => TRUE,
  );
  $form['actions']['#type'] = 'actions';
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Assign tasks'),
  );
  return $form;
}