Reputation: 2814
I have a textfield in a Panel. For example:
{
xtype:'textfield',
id:'usap8',
width:199,
height:26,
colspan:1,
margin: '1 0 1 0',
allowBlank: false,
fieldStyle: 'text-align: center;'
}
Will I be able to restrict the panel submission? If not, what is the use of allowBlank
config?
Upvotes: 1
Views: 11187
Reputation: 20224
allowBlank
does not automatically restrict form submission.
Instead, it is a config that is for instance relevant if you ask whether the form is valid:
if(form.isValid()) form.submit()
In the isValid
function, all fields are asked whether they are valid:
invalid = me.getFields().filterBy(function(field) {
return !field.validate();
});
field.validate()
calls field.isValid()
, which calls field.getErrors()
.
The Ext.form.field.Text
has the following line in its function getErrors
:
if (trimmed.length < 1 || (value === me.emptyText && me.valueContainsPlaceholder)) {
if (!me.allowBlank) {
errors.push(me.blankText);
}
and HERE the config you have said has the effect that an error is thrown if the field is blank.
That error then ripples back through aforementioned functions until form.isValid()
returns false
(but you could also find out about the error if you call field.validate()
, field.isValid()
or field.getErrors()
manually)...
Upvotes: 3
Reputation: 426
For restricting form panel text value submission, use
submitvalue: false
Refer: http://docs.sencha.com/extjs/5.0/apidocs/#!/api/Ext.form.field.File-cfg-submitValue
While, allowBlank:false will restrict the form submission if the field is blank.
Upvotes: 1
Reputation: 51
allowBlank
simply tells the Validator that your field may or may not be empty upon validation/submission.
If you do validation of panel/form then allowBlank:false
should make sure you can't proceed with a blank/empty field there.
Upvotes: 0