Jinah Adam
Jinah Adam

Reputation: 1125

Extjs Using Radio Buttons with getFieldValues

I'm having trouble submitting radio button values. I have two radio buttons set up like this:

{
xtype: 'radio',
fieldLabel: 'Employment Type',
boxLabel: 'Documented',
name: 'employment_type',
checked: true,
inputValue: 'documented'
},
{
xtype: 'radio',
boxLabel: 'Contracted',
name: 'employment_type',
inputValue: 'contracted'
}

I am submitting the form this way using an AJAX call.

var myParams = { 
employee: form.getFieldValues()
}   

Ext.Ajax.request({
url: '/employees',
jsonData: myParams,
success: function(result, request){
...

In the server console I see the parameter passed as shown below, which is wrong.

"employment_type"=>[false, true]

How I'd like to have the parameter passed:

"employment_type"=>"documented"

Upvotes: 0

Views: 3953

Answers (1)

ChrisR
ChrisR

Reputation: 14447

Use form.getForm().getValues() instead of form.getFieldValues() as illustrated here: http://jsfiddle.net/chrisramakers/eL7qg/

But on another note, why aren't you submitting by just calling form.getForm().submit() and let Ext.form.BasicForm handle all the data gathering?

Upvotes: 2

Related Questions