You are here

public function ContinuousJobForm::ajaxSourceLanguageSelect in Translation Management Tool 8

Ajax callback to fetch the options for target language select.

Parameters

array $form: The form.

\Drupal\Core\Form\FormStateInterface $form_state: The form state.

Return value

mixed Target language select array.

File

src/Form/ContinuousJobForm.php, line 92

Class

ContinuousJobForm
Form controller for the job edit forms.

Namespace

Drupal\tmgmt\Form

Code

public function ajaxSourceLanguageSelect(array $form, FormStateInterface $form_state) {
  if ($el = $form_state
    ->getTriggeringElement()['#value']) {
    $selected_option = [
      $el => tmgmt_available_languages()[$el],
    ];
    $options = array_diff(tmgmt_available_languages(), $selected_option);
    $form['info']['target_language']['#options'] = $options;
    return $form['info']['target_language'];
  }
}