public function ExportTermsForm::myAjaxCallback in Taxonomy Manager 2.0.x
File
- src/
Form/ ExportTermsForm.php, line 181
Class
- ExportTermsForm
- Form for exporting given terms.
Namespace
Drupal\taxonomy_manager\FormCode
public function myAjaxCallback(array &$form, FormStateInterface $form_state) {
// Prepare our textfield. check if the example select field has a selected option.
if ($selectedValue = $form_state
->getValue('example_select')) {
// Get the text of the selected option.
$selectedText = $form['example_select']['#options'][$selectedValue];
// Place the text of the selected option in our textfield.
$form['output']['#value'] = $selectedText;
}
// Return the prepared textfield.
// return $form;.
$response = new AjaxResponse();
$response
->addCommand(new ReplaceCommand('#edit-output', $form['output']));
return $response;
}