View Full Version : Form Values won't post, only Text
davidd
1 Jul 2007, 6:42 PM
I'm having real trouble trying to get my form values to post instead of my text values.
I've created an array for the combobox.
Then created a simplestore.
Then connect the simplestore to the combobox, however, when I send the variables to my php page, they send just the TEXT values, and not the value I'm setting in the valueField property.
var actContactMeth = new Array (['skype','Skype Account'],['priphone','Primary Phone#'],['priemail','Primary Email'],['secphone','Secondary Phone#'],['secemail','Secondary Email']);
var clContactMethod_st = new Ext.data.SimpleStore({
fields: ['value', 'text'],
data : actContactMeth
});
var clContactMethod_tf = new Ext.form.ComboBox({
store: clContactMethod_st,
displayField:'text',
valueField:'value',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText:'Primary Contact...',
selectOnFocus:true,
fieldLabel: 'Primary Contact',
name: 'clContactMethod',
allowBlank:false
});
Please help.
David...
How are you posting to server?
If your sending the parameters manually you can try: clContactMethod_tf.getValue()
davidd
1 Jul 2007, 9:22 PM
I'm not trying to post them manually I'm just trying to do a submit.
The problem I'm having is that when I check the fields before I submit I get different responses from different functions.
If I use:
form_instance_create.findField(curChk).getValue()
It shows me the actual VALUE and not the TEXT equivalent.
If I use:
form_instance_create.getValues(true)
I get all the TEXT and no values.
Here's my submit function:
if (form_instance_create.isValid()) {
form_instance_create.submit({
waitMsg:'Creating new account now...',
reset: false,
scope:form_instance_create,
failure: function(form_instance_create, action) {
Ext.MessageBox.alert('Error Message', action.result.errorInfo);
},
success: function(form_instance_create, action) {
Ext.MessageBox.alert('Confirm', action.result.info);
aAddInstanceDlg.hide();
ds.load({params:{start:0, limit:myPageSize}});
}
});
}else{
Ext.MessageBox.alert('Errors', 'Please fix the errors noted.');
}
David...
P.S. Tonic, is there a way to update the values properly before they are submitted?
davidd
1 Jul 2007, 10:09 PM
Found the solution by spending the last 4 hours in the forums.
Finally found it.
Added hiddenName to the combobox function.
var clContactMethod_tf = new Ext.form.ComboBox({
store: clContactMethod_st,
displayField:'text',
valueField:'value',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText:'Primary Contact...',
selectOnFocus:true,
fieldLabel: 'Primary Contact',
name: 'clContactMethod',
hiddenName:'value',
allowBlank:false
});
David...
ToNiC
1 Jul 2007, 10:18 PM
I'm not sure why form_instance_create.getValues(true) would return the text value from the combo box element unless the value property is not set in the dom. I would try giving the combo box a name attribute.
Anyways, you can update values before they are sent. Just add a 'beforeaction' listener to the Form object and listen for the submit action and adjust the form values there.
Or i think its possible to add a baseParams: {contactId: this.clContactMethod_tf.getValue() } property under the submit config option. (i hope im scoping that variable properly)
ToNiC
1 Jul 2007, 10:22 PM
Oh i thought valueField did that automatically, tkx for posting result. good to know :P
davidd
2 Jul 2007, 12:04 AM
Thanks for all the suggestions Tonic.
It got my brain moving in the right direction.
David...
ZooKeeper
2 Aug 2007, 1:46 PM
Thanks a lot man. Sometimes it's not that easy to trick Ext to do the thing u want, getting all this unexpected results out of the blue.
I think guys should work toward fixing all this small issues, which make Ext's forum my homepage..
Powered by vBulletin® Version 4.2.3 Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.