Results 1 to 6 of 6

Thread: load form data into fields in nested container

  1. #1

    Question load form data into fields in nested container

    Hi all!

    I'm having some troubles loading form data (populating fields) into fields which are located in a nested container in the form.

    I went from this example (form 5).
    Code is as follows:
    PHP Code:
    MyForm Ext.extend(Ext.form.FormPanel, {

        
    initComponent: function () {
            var 
    config;

            
    config = {
                
    url'save.php',
                
    reader: new Ext.data.JsonReader({
                    
    idProperty'id',
                    
    fields: ['id''introduction''title''content']
                }),
                
    items: [{
                    
    xtype'textarea',
                    
    name'introduction'
                
    }, {
                    
    xtype'tabpanel',
                    
    plaintrue,
                    
    activeTab0,
                    
    deferredRenderfalse,
                    
    defaults: {layout'form'},
                    
    items: [{
                        
    title'Foo',
                        
    items: [{
                            
    xtype'textfield',
                            
    name'title'
                        
    }, {
                            
    xtype'textarea',
                            
    name'content'
                        
    }]
                    } 
    /* more tabs */]
                }]
            };

            
    Ext.apply(thisExt.apply(this.initialConfigconfig));
            
    MyForm.superclass.initComponent.apply(thisarguments);

            
    this.load({
                
    url'data.php'
            
    });
        }

    }); 
    Example response:
    Code:
    {"id":1,"introduction":"Intro","title":"Foo","content":"Lipsum..."}
    While i was digging i discovered that 'Ext.form.BasicForm.findField' only looks in it's own 'items' collection and doens't cascade/recurse into underlying containers. Therefore it only finds the 'introduction' field and populated that, but not the 'title' and 'content' fields.

    Does anyone have an idea how to solve/work around this?

    Thank in advance,
    Zogs

  2. #2

    Default

    I copied your code exactly (and added a line to create a new MyForm() and render it) and it works for me... I see all 3 fields populated.

    http://i52.tinypic.com/14ub67l.jpg

    [EDIT]
    I tested with ext-3.3.1
    Johnathan Hebert

  3. #3

    Default

    johnathan,

    thanks for your reply. In all honesty, i haven't tested the -exact- code i posted. It's a stripped version of what i'm really working with, but is essentially the same.
    I'm surprised it works for you. Guess i need to run some more (isolated) tests..

    Zogs

  4. #4

    Default

    What version of Ext are you using?
    Johnathan Hebert

  5. #5

  6. #6

    Default

    johnathan,

    Found it! Typo in reader config (fields did not match response). ><
    I'll be in a corner crying if anyone needs me..

    Zogs.

Similar Threads

  1. getFieldValues() Is not returning fields inside nested panels and container
    By DaviBaldin in forum Ext 3.x: Help & Discussion
    Replies: 16
    Last Post: 5 Nov 2010, 11:25 AM
  2. Tabs in Form Example by Saki. Adding fields into form's nested tab panel.
    By santail in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 4 Sep 2009, 3:53 AM
  3. How to submit a form with fields nested in Tab Panel?
    By terence in forum Ext 3.x: Help & Discussion
    Replies: 3
    Last Post: 26 Jul 2009, 11:15 AM
  4. Load data from database into Form Fields
    By saravanan.sbm in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 8 May 2009, 12:57 AM

Posting Permissions

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