View Full Version : AllowBlank false and Hidden true - Form Submit

28 Sep 2009, 4:09 AM

If I have a field with allowBlank : false and hidden : true, I cannot submit the form if this field is empty.

I don't know if this is really a bug or a "ExtJS behaviour"...
From my point of view the "hidden" setting should wins again allowBlank because there is not way for the user to set a value to it.

I have this case because I have dinamyc forms...

This is a test case:

<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
<link rel="stylesheet" type="text/css" href="lib/extjs/resources/css/ext-all.css" />
<script type="text/javascript" src="lib/extjs/adapter/ext/ext-base-debug.js"></script>
<script type="text/javascript" src="lib/extjs/ext-all-debug.js"></script>
function handleSubmittedFormFailure(aForm, aAction) {
switch (aAction.failureType) {
case Ext.form.Action.CLIENT_INVALID:
case Ext.form.Action.CONNECT_FAILURE:
case Ext.form.Action.SERVER_INVALID:
Ext.Msg.alert("SERVER_INVALID", aAction.result.msg);
Ext.onReady(function () {
var vViewport = new Ext.Viewport({
layout: 'border',
items: [{
id: 'myform',
xtype: 'form',
title: 'Test ItemSelector',
region: 'center',
autoHeight: true,
layout: 'form',
items: [{
xtype: 'textfield',
fieldLabel: 'visible fiels',
id: "field1",
name: "field1",
allowBlank: false,
hidden: false,
hideLabel: false,
msgTarget: 'side'
xtype: 'textfield',
fieldLabel: 'hidden field',
id: "field2",
name: "field2",
allowBlank: false,
hidden: true,
hideLabel: true,
msgTarget: 'side'
buttons: [{
text: 'Submit',
handler: function () {
// used to check the error field - Begin
function (f) {
if (!f.isValid()) alert(f.id);
// used to check the error field - End
clientValidation: true,
url: 'TestSubmiForm.html',
failure: handleSubmittedFormFailure

I believe that the isValid function should bypass not only disabled field but also hidden field...


isValid: function (preventMark) {
if (this.disabled || this.hidden) {
return true;

What think ExtJS Team about it ?


30 Sep 2009, 10:37 PM
Can ExtJS Team tell me if this is considered a bug ? or that you think about it..

30 Sep 2009, 11:17 PM
I think you have your title the wrong way round. Confused me for a while.

Yes, it might seem strange, but technically it's correct.

The field has allowBlank: false, and so the form is invalid.

You do not want invalid fields to be submitted to the server.

I can see a case for a disableOnHide: true config for Fields which would be useful in your case.

1 Oct 2009, 2:37 AM
Ty Animal.. and sorry.. I make a mistake on the title.. I fix it now...

I believe (in my cases...) I cannot use

disableOnHide: true

because disabled field are not submitted on the server (when the I submit the form).
I need to submit also field value..

I should set disableOnHide: true only when field are Hidden (but this state can be changed dinamically...) and mandatory (allowBlank : false) but only if value is not set...

Too many combination.. cases....I prefer to override Ext.form.Field function...

Ext.override(Ext.form.Field, {
isValid: function (preventMark) {
if (this.disabled || this.hidden) return true;
var restore = this.preventMark;
this.preventMark = preventMark === true;
var v = this.validateValue(this.processValue(this.getRawValue()));
this.preventMark = restore;
return v;
validate: function () {
if (this.disabled || this.hidden || this.validateValue(this.processValue(this.getRawValue()))) {
return true;
return false;


1 Oct 2009, 3:00 AM
So you have allowBlank: false, but you actually want to allow blank? I'm not getting the idea.

1 Oct 2009, 3:28 AM
I assume the OP has a setup that shows/hides certain fields based on context or the values of other fields. If the fields are hidden they are not applicable and should not be validated.

The only strange thing is that the OP still wants these hidden fields to be submitted. If I had written the server software I would have programmed it so that fields that are not applicable wouldn't need to be submitted. In that case, simply disabling the fields would have worked.

10 Dec 2014, 7:54 PM
I can see a case for a disableOnHide: true config for Fields which would be useful in your case.

Does this config exist yet? I have a Combobox that can not be blank when visible, however when the field is hidden, it should be blank. I am using form.isValid() to check the form before submitting and since my field is hidden and has allowBlank: false, it invalidates the form. When hidden, I do not need to submit it.