Reputation: 41117
How do I create a form panel with smaller parts. The smaller parts should be reusable in the form panel.
Upvotes: 4
Views: 658
Reputation: 23983
I am using helper for this. Here is a example that should show you the trick.
/// limitForm : array with all ellemts that should be taken from the inner form. can be null or empty to take all
FormContent.loginForm = function (limitForm) {
var defaults = [
{/* this has the ID 0 */
xtype: 'Fieldset',
title: 'Username',
layout: 'form',
items: [
{
xtype: 'panel',
layout: 'form',
header: false,
hideBorders: true,
bodyBorder: false,
border: false,
height: 40,
items: [
{
xtype: 'textfield',
fieldLabel: 'Username',
regex: /^[\w\s\.]*$/,
regexText: 'No special chars allowed in this field',
anchor: '100%',
name: 'LoginName'
}
]
}
]
}
,
{/* this has the ID 1 */
xtype: 'Fieldset',
title: 'Additional data',
layout: 'form',
items: [
{
xtype: 'panel',
layout: 'column',
header: false,
border: false,
bodyBorder: false,
height: 40,
items: [
{
xtype: 'panel',
layout: 'form',
header: false,
columnWidth: 0.5,
hideBorders: true,
bodyBorder: false,
border: false,
items: [
{
xtype: 'textfield',
fieldLabel: 'Title',
anchor: '100%',
name: 'Title'
}
]
},
{
xtype: 'panel',
layout: 'form',
header: false,
columnWidth: 0.5,
style: 'margin-left: 18px',
hideBorders: false,
border: false,
bodyBorder: false,
labelWidth: 65,
items: [
{
xtype: 'textfield',
fieldLabel: 'Title',
anchor: '100%',
name: 'Title'
}
]
}
]
}
}
];
if (limitForm) {
var ds = [];
for (var i = 0, len = limitForm.length; i < len; i++) {
ds.push(defaults[limitForm[i]]);
}
defaults = ds;
}
return defaults;
}
If you want to reuse it you can modify the function params with config arrays or fieldnames (the names must changes otherwise just one field will get submitted). But I think it should show you the trick.
For sure this mus be loaded in the mainform!
Upvotes: 4