Results 1 to 10 of 10

Thread: how to dynamically add hidden field to form?

  1. #1
    Ext User
    Join Date
    Jun 2007
    Posts
    14
    Vote Rating
    0
      0  

    Smile 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,615
    Vote Rating
    54
      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
      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
      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
      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
    3
      0  

    Default

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

  7. #7
    Sencha User jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    DC Area =)
    Posts
    16,364
    Vote Rating
    86
      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
      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
    Sencha User jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    DC Area =)
    Posts
    16,364
    Vote Rating
    86
      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
      0  

    Default containerEl not defined

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •