I wont build a User Contact Form, with 2 tabs containing the same fields but on different language. Using MVC and ExtJS 4.0.7.
I wont to reuse the userinfo panel .. and just give it a paramether langKey = en/fr
The tab widget with user information looks like this:
Ext.define('MyApp.view.user.FormUserInfo', {
extend: 'Ext.Panel',
alias: 'widget.userinfo',
defaultType: 'textfield',
items: [
{
name: 'first_name['+langKey+']',
}, {
name: 'last_name['+langKey+']',
}]
});
And the form loads it like this:
Ext.define('MyApp.view.user.Form', {
extend: 'Ext.FormPanel',
xtype: 'form',
items: [
{
xtype: 'tabpanel',
activeTab: 2,
items:[
{
xtype: 'userinfo',
cls: 'en',
tabConfig: {
title: 'Contact Details(EN)'
}
},{
xtype: 'userinfo',
cls: 'de',
tabConfig: {
title: 'Contact Details(DE)'
}
}]// /TabPanel.items
}]// /FormPanel.items
});
In fact the form contains 10+ fields and 2 or more languages ..so I need a good control over the data.
Any way to pass a variable when using the widget or a property that I can use ?
i tried to use the panel class (cls) 'first_name['+this.cls+']' but the scope is wrong or something (and is a bit ugly).
One easy way to do this is to add a custom config property to your user info panel, and then apply the custom config value to the field names within initComponent().
Example:
You can then pass through the custom config, just like you would with any other:
Here’s a live example of it.