I have an issue that is somewhat similar to: #1163066: Add the ability to use radio buttons on the Add to Cart form and #1038320: Replace the "magic configuration" of attribute fields with explicit settings

I am able to change the add to cart form select list to display as radio buttons with this code:

function mymodule_form_alter(&$form, $form_state, $form_id) {
  if (substr($form_id, 0, 30) == 'commerce_cart_add_to_cart_form') {
    $form['product_id']['#type'] = 'radios';    	
  }        
}

Although it is functional, I see the following error:

Notice: Undefined index: #options in form_process_radios() (line 2933 of xxx/src/includes/form.inc).

Does anybody know why this error is happening?

Comments

rszrama’s picture

Status: Active » Patch (to be ported)

I'm guessing the problem is that your code is getting executed for both single and multiple product Add to Cart forms, causing this error to show up on single product forms where $form['product_id'] is normally going to be just a hidden field without an #options array.

rszrama’s picture

Status: Patch (to be ported) » Fixed

Definitely meant to mark fixed. : P

lexfunk’s picture

You were absolutely correct @rszrama. Thank you for your help.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.