PDA

View Full Version : How to add a field in the form when a button is clicked



arafat_alam
23 Nov 2011, 3:24 AM
I have a form panel and a button.i want to add a field in the form when the button is clicked..here is the model


Ext.regModel('Contact', {
idProperty: 'id',
fields: [
{ name: 'name', type: 'string' },
{ name: 'phone', type: 'string' },
{ name: 'email', type: 'string' },
{ name: 'address', type: 'string' },
],
validations: [
{ type: 'presence', field: 'name', message: 'Please Enter A Contact Name' },
{ type: 'format', field: 'phone', message: 'Please Enter Phone Number', matcher: /[0-9]/ }
]
});


and here is the form


AddressBook.views.contactEditor = new Ext.form.FormPanel({ id: 'contactEditor',
items: [
{
xtype: 'textfield',
name: 'name',
label: 'Name',
required: true
},
{
xtype: 'textfield',
name: 'phone',
label: 'Phone',
required: true
},
{
xtype: 'emailfield',
name: 'email',
label: 'Email'
},
{
xtype: 'textareafield',
name: 'address',
label: 'Address'
},
],
dockedItems: [
AddressBook.views.contactEditorTopToolbar,
AddressBook.views.contactEditorBottomToolbar,

]
});

i want another phone field in the form when a button is clicked....can any one help..please??

flanders
23 Nov 2011, 3:31 AM
I would go about it like this:

- Add a button to the form
- Listen for the click event
- Add an form item on the click event

I think you should provide more info on what you need to know or what the problem is. Maybe show an attempt. We're glad to help but we're not gonna write your code. (Or to speak for myself, I am not ;))