I have created a form with one field of "select" type. Whenever the user selects an option, I need to append the URL with the #options key. My form looks like this:

 $form['language'] = array(
  '#type' => 'select',
  '#options' => $this->getOptions(),

return $form;

When the user selects an option, is this action proceeded in submitFrom?

public function submitForm(array &$form, FormStateInterface $form_state) {
 drupal_set_message("User selected something");

I try this, but nothing happens. When can I do some further actions, when user selects something? Do I need some jqury to inspect when the user selected something?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.