You are here

public function AssignMultiple::buildForm in Translation Management Tool 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

translators/tmgmt_local/src/Form/AssignMultiple.php, line 62

Class

AssignMultiple
Provides a node deletion confirmation form.

Namespace

Drupal\tmgmt_local\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $this->taskInfo = $this->tempStoreFactory
    ->get('task_multiple_assign')
    ->get(\Drupal::currentUser()
    ->id());
  $form_state
    ->set('tasks', array_keys($this->taskInfo));
  $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($form_state
      ->get('tasks')),
    '#required' => TRUE,
  );
  $form['actions']['#type'] = 'actions';
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Assign tasks'),
  );
  return $form;
}