PDA

View Full Version : checkbox allowblank



maneljn
21 Mar 2013, 9:39 AM
is there some config equivalent to "allowblank" in checkbox field ?

I need to add a checkbox legal confirmation and i want to stop submit if form.isValid() detects that this field is not checked

scottmartin
21 Mar 2013, 12:07 PM
I believe you are going to have to check it yourself:



Ext.create('Ext.form.Panel', {
bodyPadding: 10,
width: 300,
title: 'Pizza Order',
items: [
{
xtype: 'fieldcontainer',
fieldLabel: 'Toppings',
defaultType: 'checkboxfield',
items: [
{
boxLabel : 'Anchovies',
name : 'topping',
inputValue: '1',
itemId : 'checkbox1'
}, {
boxLabel : 'Artichoke Hearts',
name : 'topping',
inputValue: '2',
checked : true
}, {
boxLabel : 'Bacon',
name : 'topping',
inputValue: '3'
}
]
}
],
renderTo: Ext.getBody(),

buttons: [{
text: 'Save',
handler: function(btn) {
var form = btn.up('form');
var ck1 = form.down('#checkbox1').checked;
if ( (ck1 !== true) && (form.getForm().isValid()) ){
console.log('Check yourself');
}
}
}]
});