Closed (fixed)
Project:
Commerce Core
Version:
7.x-1.2
Component:
Commerce
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
27 Feb 2012 at 21:47 UTC
Updated:
23 Mar 2012 at 06:41 UTC
I'm using hook_form_alter to add in 'Please select' to the product attributes (sizes and colours) available. However, this kills the ajax updating! In other words, available sizes aren't reloaded when a user chooses a different colour. If I can't alter the choices via hook_form_alter, is there some other better way to be doing this?
Comments
Comment #1
bojanz commentedPlease share your code. You're probably doing it incorrectly, accidentally killing #ajax on the form element.
Comment #2
patrickharris commentedI'm trying to have 'Please select' when the product is first loaded. Here is the code.
The validation function works and causes no problems, but adding in the extra option 'Please select' stops the ajax working. Why would this be? Any ideas? Is there a better way to do this than hook_form_alter?
Comment #3
rszrama commentedYeah, really you can't do this because the form depends on being able to determine based on the currently selected values what product should be represented on the form. In other words, it needs each attribute to have a value, not an empty "Please select" option.
You have two recourses: 1) use JS / the theme layer to show your "Please select" text without actually changing the value of the field or 2) further alter the form so the "Please select" value is actually equated to the otherwise default value for the widget.
Comment #5
patrickharris commentedThanks Ryan!!