Add new comment | Drupal 8

Add new comment

Salman Haider (not verified)

Mon, 04/29/2019 - 08:59

Dear Drupaler,

I have a scenario where I alter options of a form fields with ajax callbacks.
Like I have A, B, C, D fields (all dropdowns)

Selecting any option in field A filters down option for field B, which further filters options to a limited number on C and so on.

I have altered these options based on selections, using Ajax callbacks in Drupal8 and handled current value through $form_state and returning updated select lists with updated and filtered options through use Drupal\Core\Ajax\AjaxResponse;
use Drupal\Core\Ajax\ReplaceCommand;

Success: The form works great, screenshot:
But the problem is when I submit the form, I get this error "An illegal choice has been detected. Please contact the site administrator."

How do I get it to resolve and get this done?
Anyone who could help?

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.