PDA

View Full Version : how to dynamically add hidden field to form?



littlegg
23 Sep 2007, 5:03 PM
i use


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?

Animal
23 Sep 2007, 11:14 PM
form.el.createChild({tag:'input', type:'hidden', name:'nodeId', value: '1'});

littlegg
24 Sep 2007, 12:24 AM
it doesn't work.

alert(form.el)
shows 'undefined'

the form is dynamically created by


form = new Ext.form.Form({
method:'post',
labelWidth: 75
});

haibijon
24 Sep 2007, 5:18 AM
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.

littlegg
24 Sep 2007, 4:23 PM
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


alert(form.findField('nodeId'));


it shows 'null'

devnull
24 Sep 2007, 4:36 PM
I use the HiddenField extension that someone wrote (sorry, dont remember who).

jay@moduscreate.com
24 Sep 2007, 4:44 PM
Do you need a hidden field? Why not just pass the data as a parameter on the form.submit action?

littlegg
24 Sep 2007, 6:39 PM
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.

jay@moduscreate.com
25 Sep 2007, 10:20 AM
n/p. i faced the same problem a while back. :) this forum pwns.

shyam63
27 Oct 2011, 1:19 AM
when using form.render(containerEl), i am getting error.
how to define conatinerEl?