View Full Version : ItemSelector and allowBlank : false
dtex-lab
6 Nov 2009, 3:00 AM
Hi
It seems that ItemSelector doesn't support the Field's allowBlank attribute.
I'm creating a mandatory ItemSelector, so I try to set allowBlank : false, but user can submit the form also if he doesn't select an item from the available list.
I try to do a test case calling the isValid funcion on the ItemSelector but it returns always true.
How can I have an ItemSelector "mandatory" ? (where the user must select at least 1 items?)
Thanks
dtex-lab
8 Nov 2009, 2:32 AM
Hi
Nobody can help me for this issue?
thanks
Condor
9 Nov 2009, 12:14 AM
ItemSelector descends from Ext.form.Field and not from Ext.form.TextField, so it doesn't have an allowBlank config option.
You could try adding it:
Ext.override(Ext.ux.form.ItemSelector, {
allowBlank : true,
blankText : 'This field is required',
validateValue: function(value){
if(value.length < 1 && !this.allowBlank){
this.markInvalid(this.blankText);
return false;
}
}
});
(disclaimer: completely untested code)
dtex-lab
10 Nov 2009, 12:19 AM
Hi Condor
thank you
Your code was wrong.
This is the right one:
Ext.override(Ext.ux.form.ItemSelector, {
allowBlank: true,
blankText: 'This field is required',
validateValue: function (v) {
if (this.toMultiselect.store.getCount() < 1 && !this.allowBlank) {
this.markInvalid(this.blankText);
return false;
}
}
});
I believe this is a missing important feature in the ItemSelector
All form fields MUST have the allowBlank feature.
Will this little implementation be distributed as standard in next release?
Should I open a Bug or Feature REquest post ?
Thanks
Condor
10 Nov 2009, 12:26 AM
This is not a bug, so you could create a feature request for it.
ps. If you really feel that this is important then you should contact support, because feature requests usually don't have a high priority.
Powered by vBulletin® Version 4.1.5 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.