1. #1
    Ext User
    Join Date
    Jun 2007
    Posts
    14
    Vote Rating
    0
    littlegg is on a distinguished road

      0  

    Smile how to dynamically add hidden field to form?

    how to dynamically add hidden field to form?


    i use
    Code:
    form.add({
      new Ext.form.TextField({
    			            name: 'nodeId',
    			            hidden:true
    			        })})
    to add a hidden field to a form,but the result is not i want, it shows a blank ':' in one row. how to completely hide this field?

  2. #2
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,496
    Vote Rating
    44
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    Code:
    form.el.createChild({tag:'input', type:'hidden', name:'nodeId', value: '1'});

  3. #3
    Ext User
    Join Date
    Jun 2007
    Posts
    14
    Vote Rating
    0
    littlegg is on a distinguished road

      0  

    Smile


    it doesn't work.
    Code:
    alert(form.el)
    shows 'undefined'

    the form is dynamically created by
    Code:
    form = new Ext.form.Form({
    						method:'post',
    				        labelWidth: 75 
    				    });

  4. #4
    Ext User haibijon's Avatar
    Join Date
    Mar 2007
    Posts
    105
    Vote Rating
    0
    haibijon is on a distinguished road

      0  

    Lightbulb


    form.el won't be set until the form.render method has been called. Try Animal's code after calling form.render(containerEl), works for me.

  5. #5
    Ext User
    Join Date
    Jun 2007
    Posts
    14
    Vote Rating
    0
    littlegg is on a distinguished road

      0  

    Default


    Quote Originally Posted by haibijon View Post
    form.el won't be set until the form.render method has been called. Try Animal's code after calling form.render(containerEl), works for me.

    thanks, yes, form.el works after form.render called. but another question, how to set value of this hidden field?

    i tried
    Code:
    alert(form.findField('nodeId'));
    it shows 'null'

  6. #6
    Ext User
    Join Date
    Jul 2007
    Posts
    3,128
    Vote Rating
    1
    devnull is an unknown quantity at this point

      0  

    Default


    I use the HiddenField extension that someone wrote (sorry, dont remember who).

  7. #7
    jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    Frederick MD, NYC, DC
    Posts
    16,353
    Vote Rating
    77
    jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all

      0  

    Default


    Do you need a hidden field? Why not just pass the data as a parameter on the form.submit action?

  8. #8
    Ext User
    Join Date
    Jun 2007
    Posts
    14
    Vote Rating
    0
    littlegg is on a distinguished road

      0  

    Default


    Quote Originally Posted by djliquidice View Post
    Do you need a hidden field? Why not just pass the data as a parameter on the form.submit action?
    it's a good idea. i make it work in your way. thank you very much.

  9. #9
    jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    Frederick MD, NYC, DC
    Posts
    16,353
    Vote Rating
    77
    jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all

      0  

    Default


    n/p. i faced the same problem a while back. this forum pwns.

  10. #10
    Sencha User
    Join Date
    Sep 2011
    Posts
    4
    Vote Rating
    0
    shyam63 is on a distinguished road

      0  

    Default containerEl not defined

    containerEl not defined


    when using form.render(containerEl), i am getting error.
    how to define conatinerEl?