PDA

View Full Version : form add field dynamic



gimler
26 Nov 2007, 6:58 AM
hello,

how can i add a field to a rendered form???

para
26 Nov 2007, 9:14 AM
My solution is to create them all and simply show(), hide(), and change combo box options.
Might not work for your case, but works beautifully for mine.

heidtmare
26 Nov 2007, 9:42 AM
Here I have a button inside of a fieldset that when clicked
creates a new field and inserts it beneath the button.


items :[{
xtype:'button',
icon: './add.gif',
cls: 'x-btn-text-icon',
text: 'Add a field',
handler: function(){
Ext.getCmp('id-of-componet-to-insert-into').insert(2, {
xtype:'textfield',
fieldLabel:'Field'
});
Ext.getCmp('id-of-componet-to-insert-into').doLayout();
}
}

kohwuyea
26 Nov 2007, 11:15 PM
Thanks,heidt,and then I will apply the code from your post.

gimler
27 Nov 2007, 2:15 AM
it works but the label would not created ;(



form = new Ext.FormPanel({
labelWidth:75
, layout:'fit'
, items:[{
layout:'form'
, autoHeight:true
, items:[{
fieldLabel:Dissz.Language.form.title
, name:'element[title]'
, xtype:'textfield'
}]
}]
});

form.insert(2, {
xtype:'textfield'
, fieldLabel:'Field'
, id:'blubb'
});
form.render('innerContent1');

form.insert(2, {
xtype:'textfield'
, fieldLabel:'Field'
, id:'blubb2'
});
form.doLayout();

dieyoudie
16 Dec 2007, 2:05 AM
I have similar problem. put the <div id='tmpAnchor'></div> in the form and try to dynamically decide to put textbox here or just a string
right now i try to create textfield then try to render
txtTest.render("tmpAnchor");
the textbox is there but the field label wont show up, neiter did the invalid msg icon.
got "B has no properties" error when the box is blur.
did you figure out how to fix this?