PDA

View Full Version : Radiogroup selection not triggering formbind button



jeremym
29 Mar 2012, 12:44 PM
I've got a form with a dynamic number of radiobuttons clumped under a single radiogroup that is part of my form. The form pops up based on some other parts of the application so I've got a shell class for the form defined as a view that extends off of Ext.form.Panel , later I use an ext.create to instantiate the form panel and then call show on it. The form seems to be working fine except I'm having trouble tying my "apply/submit" button to having a radio button selected. If I formBind:true the apply button it starts off disabled and stays that way, no matter whether I select the radio buttons or not. I removed the formbind and instead in the handler thats called when the form is actually submitted did a check for validation and the form is indeed valid when a button is selected and invalid when no selection has been made... so the allowBlank:false in the radiogroup appears to be working as advertised. I'm not sure what I'm overlooking in tying the submit button to the form though, and a forum and google search produced no similar issues... so I must be overlooking something.

view code (names sanitized):

Ext.define('myFormPanel',{
extend: 'Ext.form.Panel',
alias: 'widget.myFormPanel',

height: 300,
width: 200,
floating: true,
frame: true,

buttons: [{
text: 'submit',
formBind: true
},
{
text: 'cancel',
handler: function(){
var formpanel = this.up('form');
formpanel.cancelClicked();
}
}],

cancelClicked: function(){
this.close();
}
});

and the code where its instantiated:

var buttonArray = [];
var i;
for(i = 0; i < store.getCount(); i++){
buttonArray[i] = {
boxLabel : store.getAt(i).data.name,
inputValue: store.getAt(i).data.key
};
}

var formPanel = Ext.create('myFormPanel', {
items: [{
xtype: 'radiogroup',
columns: 1,
defaults: {xtype: 'radio', name: 'rb'},
allowBlank: false,
items: buttonArray
}]
});
formPanel.show();

I've sanitized the names a bit, so if theres typos they may be just in the post rather than in the real source, but I'll check if anyone notices something... I also have a listener on the "click" event for the submit button that is added after this snippet of code, it would be strange if that impacted form validation enabling the button, but I figure its worth mentioning just in case...

jeremym
29 Mar 2012, 12:59 PM
as an addendum, if I set one of the radio buttons to be selected by default the formbind correctly enables the submit button from the start