PDA

View Full Version : accessing form fields



nickweavers
18 Nov 2009, 4:09 PM
I have a form that has a couple of fieldsets in it, one of which is shown below:


var personRoleFieldset = {
xtype: 'fieldset',
labelWidth: 90,
title: 'Role',
layout: 'column',
buttons: formButtons,
buttonAlign: 'left',
items: [{
// Fieldset in Column 1
xtype: 'fieldset',
columnWidth: 0.3,
defaultType: 'checkbox',
border: false,
items: [{
id: 'employee',
fieldLabel: 'Employee',
name: 'employee'
},{
id: 'applicant',
fieldLabel: 'Applicant',
name: 'applicant'
},{
id: 'client',
fieldLabel: 'Client',
name: 'client'
}]
},{
// Fieldset in Column 1
xtype: 'fieldset',
columnWidth: 0.4,
defaults: { width: 50 },
defaultType: 'textfield',
border: false,
items: [{
id: 'id_employee',
fieldLabel: 'EmployeeID',
name: 'id_employee',
disabled: true
},{
id: 'id_applicant',
fieldLabel: 'ApplicantID',
name: 'id_applicant',
disabled: true
},{
id: 'id_client',
fieldLabel: 'ClientID',
name: 'id_client',
disabled: true
}]
}]
};

I am prefilling the form with data from a row that a user has selected on a grid within the same form:

grid.getSelectionModel().on('rowselect', function(sm, rowindex, record) {
personForm.getForm().loadRecord(record);
});
The rendered form is as shown in the attachment.
I would like to change the checkboxes so they default to being disabled in the config and are only enabled if their associated ID fields (shown to the right of them) are blank.
How do I access the checkbox objects? I tried this:


grid.getSelectionModel().on('rowselect', function(sm, rowindex, record) {
personForm.getForm().loadRecord(record);
if (record.data.id_employee=='') {
personForm.getForm().getName('employee_cb').enable();
}
if (record.data.id_applicant=='') {
personForm.getForm().getName('applicant_cb').enable();
}
if (record.data.id_client=='') {
personForm.getForm().getName('client_cb').enable();
}
});

But Firebug gives me "personForm.getForm().getName is not a function".

TIA.

nickweavers
18 Nov 2009, 4:34 PM
Answer found here: http://www.extjs.com/forum/showthread.php?p=100191#post100191