Hello,

I asked this question by creating Issue in Drupal Commerce module page last week, but no one reply. So I try to post it here maybe someone have an idea. (https://www.drupal.org/project/commerce/issues/2961967)

This is my question.

I'm using Drupal Commerce for most of my website projects. But I have never face this problem before.
I want to test the whole process of buying a product & stuck at the Checkout page. Suddenly there is a message 'There are no available payment methods configured'. I pick payment method 'Bank Transfer' & nothing happen. No payment details appear. I try to proceed payment (Continue to next step) & after that detail on 'Bank Transfer' appear with message (An illegal choice has been detected. Please contact the site administrator). I clicked again (Continue to next step) & my buying process success without problem.

I checked error log & there is an error:
'Notice: Undefined index: form_build_id in ajax_get_form() (line 325 of /home/website/public_html/abc/includes/ajax.inc).'.

Line 325 in ajax.inc is: 

$form_build_id = $_POST['form_build_id'];

Any idea how to solve this problem?
Thank you in advance

Comments

RumyanaRuseva’s picture

Usually when something fails and then succeeds the problem is in cache. This error 'illegal choice' most often appears in two scenarios:

  1. You open the form as anonymous user, you login in a different browser tab, and then you submit the form without refreshing the page. Or you logged in via ajax, and the page was not refreshed.
  2. Incorrect full-page caching where the form was built for a different user, and it's not valid for your own.

I have no idea if these fit in the scenario you described.

yoshiet p’s picture

In my case, it happened in custom multistep ajax form. I had a radio field causing this issue and would not allow me to hit back from step 2 to step 1. So I applied  '#validated' => TRUE, in my radio field and got it fixed. If we are using a dynamically populated SELECT (dropdown) or radios via AJAX this error will pop up. When a value is not present in options array, Drupal will consider it as illegal. So the user couldn't inject an illegal value into the database.

otcassetmgmt’s picture

In my case I want this error to happen during the multiform process, because the users forget to select a radio button before proceeding, but the message says "An illegal choice has been detected. Please contact the site administrator. " is confusing to the user so does anyone know how to change the text message?

hughworm’s picture

You can change the message in the same way as any other translated string. There a tutorial here

https://www.ostraining.com/blog/drupal/translate-drupal-8-strings/

If at first you don’t succeed, call it version 1.0.

otcassetmgmt’s picture