View Full Version : Combobox Form submission issue

6 Apr 2011, 10:17 AM
Hey all,

I've got a complicated little problem that I'm just not seeing the solution for even with my attempts to hack it.

We have a taglib that serves up a form that in itself uses Spring's form taglib. My state dropdown html is created thusly:

<stateForm:element pId="stateContainer" label="State" labelId="stateLabel" contentId="stateSelect" required="true">
<form:input path="${path}state" id="stateSelect"/>
<form:errors path="${path}state" />
I create the Combobox like so (many thanks to those who helped me with my json store woes with this part):

addressService.stateSelectBox = new Ext.form.ComboBox(
allowBlank: false,
name: 'stateSelectBox',
typeAhead: true,
forceSelection: true,
mode: 'local',
triggerAction: 'all',
emptyText:'Select a State...',
applyTo: 'stateSelect',
hiddenName: 'stateCode',
valueField: 'code',
displayField: 'value',
store: addressService.stateSelectStore
You'll notice that I have a hiddenName attribute here because we need to submit the value of the state code and not the display text (which is what is happening without the hiddenName field)

The problem is that my form won't submit because the (I'm assuming) Spring form validation believes my stateSelect field is empty...which I guess it technically is.

I've tried to hack the stateSelect field on submission with failed results along the lines of:

addressService.stateSelectBox.on("submit", function() {
var stateCode = Ext.get('stateCode').getValue();
var innerHTML = "<input value=\"" + stateCode + "\" name=\"state\" id=\"state\" type=\"hidden\">" +
"<input id=\"stateSelect\" value=\"" + stateCode + "\" type=\"text\">";
addressService.stateSelectBox.dom.innerHTML = innerHTML;

Anyone else have a problem with this type of thing before? Solution thoughts?

6 Apr 2011, 11:55 AM
You can't have both a 'name' and 'hiddenName' field on the Combo. I'm thinking that the 'name' field takes priority.

Eliminate the 'name' attribute altogether and the 'hiddenName' field will become the name of the form data item to be submitted.

7 Apr 2011, 5:56 AM
Wow...thanks for the info. I never would have known that based on the API. I assumed Name was one of those things you just always had for good practice and that hiddenName ensured the data was getting submitted.

7 Apr 2011, 3:49 PM
Yeah, comboboxen are among the more obtuse ExtJs components. I got bit by the same issue as you and pulled some hair out over it; hope this saved you some grief!