PDA

View Full Version : how to use the allowBlank in afterLabelTextTpl



xunxin
7 Apr 2012, 6:52 PM
i have a field base to override the ext field base to config afterLabelTextTpl, which use allowBlank attribute, but it doesn't work and all of field appened a (*) not only for allowBlank equals to false.


Ext.define('Wy.form.field.Base',{ override : 'Ext.form.field.Base',

afterLabelTextTpl: '<tpl if="allowBlank===false"><span style="color:red;font-weight:bold" data-qtip="required">*</span></tpl>'
});

what is the correct way?

thanks in advance.

maksimenko
8 Apr 2012, 2:54 PM
Hello there,


Which version of Ext 4.1 are you using ? The allowBlank property was added recently to the labelableRenderProps in Ext 4.1 nightlies. So its possible that you are using a version that doesnt have that by default.

Try adding the allowBlank property to labelableRenderProps, something like this:



Ext.define('Wy.form.field.Base',{

override : 'Ext.form.field.Base',

labelableRenderProps: 'allowBlank,labelAlign,fieldBodyCls,baseBodyCls,clearCls,labelSeparator,msgTarget,anchor',

afterLabelTextTpl: '<tpl if="allowBlank===false"><span style="color:red;font-weight:bold" data-qtip="required">*</span></tpl>'

});


Hope it helps

xunxin
8 Apr 2012, 5:46 PM
thanks for you reply.the version is 4.1RC2 , and the labelableRenderProps include already the allowBlank attribute.i will try it again with your suggestion.

xunxin
8 Apr 2012, 8:13 PM
i try it by your suggestion, and unfortunately, it doesn't work.

xunxin
11 Apr 2012, 8:10 AM
it is very strange.

it will work well when i debug it step by step, but it will do unexpected result when run it directly without any breakpoints.

anyone can help me? thanks in advance.

maksimenko
11 Apr 2012, 10:08 AM
Hello xunxin,

Well, it's very strange... I currently have it working without any problems.

I've overridden Ext.form.field.Base, Ext.form.FieldContainer and Ext.form.HtmlEditor with some defaults.
The defaults I'm using are:


{
anchor: '100%',
msgTarget: 'none',
labelAlign: 'top',
afterLabelTextTpl: new Ext.XTemplate('<tpl if="allowBlank === false"><span class="mm-required"><sup>(*)</sup></span></tpl>', { disableFormats: true })
}

and they are working fine


it is very strange.

it will work well when i debug it step by step, but it will do unexpected result when run it directly without any breakpoints.

anyone can help me? thanks in advance.

xunxin
12 Apr 2012, 5:17 AM
it work well!
thank you very much.