Results 1 to 6 of 6

Thread: form add field dynamic

  1. #1

    Default form add field dynamic

    hello,

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

  2. #2
    Ext User para's Avatar
    Join Date
    Apr 2007
    Location
    Redmond, WA
    Posts
    918

    Default

    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.

  3. #3
    Ext User heidtmare's Avatar
    Join Date
    Mar 2007
    Location
    The Space Coast, FL
    Posts
    307

    Default

    Here I have a button inside of a fieldset that when clicked
    creates a new field and inserts it beneath the button.
    PHP Code:
    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();
        }

    I like it. Simple, easy to remember.
    ...but why is the rum gone?

  4. #4
    Sencha User
    Join Date
    Apr 2007
    Posts
    31

    Default

    Thanks,heidt,and then I will apply the code from your post.

  5. #5

    Default

    it works but the label would not created ;(

    Code:
    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();

  6. #6

    Default

    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?

Posting Permissions

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