PDA

View Full Version : Problem setting 'hidden' on form fields



zhegwood
3 Mar 2010, 8:24 AM
Hey, so I have some form fields that are set to hidden:true but when they're rendered only the input is hidden but the label is still visible. This has happened with a TextField and with a ComboBox. This didn't used to happen so I'm wondering if it's a bug in 3.1 or if something changed. Here's a snippet and a screenshot:



this.menu_name = new Ext.form.TextField({
fieldLabel: "Menu Name",
name: 'menu_name',
cls: 'form-items-container',
hidden: true,
width: 300,
value: this.menuname
});

8 Mar 2010, 7:04 AM
use xtype : "hidden"

tobiu
8 Mar 2010, 7:59 AM
hi jay,

i think he needs the fields as textField or combos, but hidden.

formLayout has a config for this:



/**
* @cfg {Boolean} trackLabels
* True to show/hide the field label when the field is hidden. Defaults to <tt>false</tt>.
*/
trackLabels: false,


which should be exactly what you are looking for.


kind regards,
tobiu

8 Mar 2010, 10:07 AM
I have no idea why that config option is even available.

8 Mar 2010, 10:08 AM
It should be default true :)

tobiu
8 Mar 2010, 12:01 PM
it should.

probably backwards compatibility....

mikeyang
4 May 2010, 6:56 PM
I've got this problem too. But no solution.

nickweavers
21 Jun 2010, 3:16 AM
I have the form


employeeJobInfoForm = new Ext.form.FormPanel({
title: 'Job Info',
region: 'center',
itemId: 'employeeJobInfoForm',
layoutConfig: {
trackLabels: true // This option means that form field labels also get hidden if their controls are hidden
},
...
items: employeeJobInfoFieldset,
...

with a field named 'primary_job_cb_ref' in the following fieldset


employeeJobInfoFieldset = {
xtype: 'fieldset',
labelWidth: 90,
title: 'Job',
items: [
{
...
},
{
xtype: 'checkbox',
id: 'primary_job_cb_ref',
fieldLabel: 'PrimaryJobRef',
name: 'primary_job_cb_ref',
disabled: true
}
]
};

When I hide the field using
employeeJobInfoForm.getForm().findField('primary_job_cb_ref').hide(); my checkbox gets hidden but the fieldLabel doesn't.

I'm using ExtJS 3.2.1 which is the version that the Changelog seems to say this property was included in and causes a hide/show to rerender the label.

Does the fact that 'primary_job_cb' is within a fieldset make a difference?

I'm using the default hideMode. Should I be using something else?

Condor
21 Jun 2010, 3:44 AM
trackLabels is not inherited by child container with layout:'form' (e.g. fieldset).

I would recommend setting trackLabels globabally, e.g.

Ext.layout.FormLayout.prototype.trackLabels = true;

nickweavers
21 Jun 2010, 5:15 AM
Thanks Condor.

Not sure what the general consensus would be, but to me it would seem more intuitive if fieldsets did inherit the trackLabels property from the parent form. Otherwise a note in the API docs to make this limitation more apparent might help make it clearer.

Animal
21 Jun 2010, 5:23 AM
3.3 defaults trackLabels to true so you won't have to worry when that's released.

4.0 will be even better. You won't need a special layout to render labels - they will be part of the Field's structure.

nickweavers
21 Jun 2010, 5:52 AM
Excellent. Thanks.

arian10daddy
24 Jun 2010, 3:14 AM
Ext.layout.FormLayout.prototype.trackLabels = true;

Works great! thanks Condor! :)