Hybrid View

  1. #1
    Sencha User
    Join Date
    Nov 2011
    Posts
    3
    Vote Rating
    0
    arafat_alam is on a distinguished road

      0  

    Default Unanswered: How to add a field in the form when a button is clicked

    Unanswered: How to add a field in the form when a button is clicked


    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
    Code:
    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
    Code:
    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??

  2. #2
    Sencha User
    Join Date
    Dec 2009
    Location
    Enschede, The Netherlands
    Posts
    327
    Answers
    16
    Vote Rating
    13
    flanders will become famous soon enough

      0  

    Default


    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 )

Thread Participants: 1

Tags for this Thread