Results 1 to 10 of 10

Thread: [solved] many forms

  1. #1

    Default [solved] many forms

    i have a project when i useing a lot of forms with many fields what will be repeating eg.

    form1 (textField1, textField2....)
    form2 (textField2, combo1...) etc.

    when i try this tutorial
    http://extjs.com/learn/Tutorial:Gett...ted_with_Forms
    the field can be use only one time. is any resolution for this?

  2. #2

    Default

    create a layout config object stored in a var, then pass it to the form constructor each time a new form is created.

  3. #3

    Default

    but i need this fields in different configurations. i haven't got forms which looks the same only some fields are repeating

  4. #4

    Default

    create the individual fields as config objects stored in arrays and include them in the form's layout config then. same concept, just applied more specifically.

  5. #5

    Default

    i'm trying to do sth like:

    Code:
    var field1 = new Ext.form.NumberField({
       fieldLabel: 'lab1',
       name: 'name1',
       id:'id1'
    });
    etc....
    for example i have 15 different fields (field1, field2...etc) and i'm trying to input fields to the forms

    Code:
    var form1 = new Ext.FormPanel({
            region:'center',
            frame:true,
            autoScroll:true,
            bodyStyle:'padding:5px 5px 0',
            width: 350,
    
            items: [
                       field1,
                       field3,...
    another FormPanel:
    Code:
    var form2 = new Ext.FormPanel({
            region:'center',
            frame:true,
            autoScroll:true,
            bodyStyle:'padding:5px 5px 0',
            width: 350,
    
            items: [
                       field3,
                       field8,...etc..
    when i do sth like this fields are only in one formPanel

  6. #6

    Default

    Code:
    var field1 = {
       fieldLabel: 'lab1',
       name: 'name1',
       id:'id1'
    };
    Code:
    var form1 = new Ext.FormPanel({
            region:'center',
            frame:true,
            autoScroll:true,
            bodyStyle:'padding:5px 5px 0',
            width: 350,
    
            items: [
                       new Ext.form.NumberField(field1),
                       new Ext.form.NumberField(field3),...
    perhaps it could even be simplified more than that, i havent actually tried it.

  7. #7

    Default

    ok it works but how to make a dynamic id? i mean that every eg. field1 should have to different id eg. id1, 1d2....etc.

  8. #8

    Default

    Assign an id when you create the items in the form panel.
    e.g.
    Code:
    function newNumberField(id, config) {
        config.id = id;
        return new Ext.form.NumberField(config);
    }
    ...

    Code:
    var field1 = {
       fieldLabel: 'lab1',
       name: 'name1',
       id:'id1'
    };
    var field3 = {
        fieldLabel: 'lab3',
        name: 'name3',
        id:'id3'
     };
     
    
    var form1 = new Ext.FormPanel({
            region:'center',
            frame:true,
            autoScroll:true,
            bodyStyle:'padding:5px 5px 0',
            width: 350,
    
            items: [
                       newNumberField('anID',field1),
                       newNumberField('anotherID', field3)
                   ]
        });

  9. #9
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    Or:

    Code:
    items: [
      new Ext.form.NumberField(Ext.applyIf({id: 'id1'}, field1)),
      new Ext.form.NumberField(Ext.applyIf({id: 'id2'}, field3)),
      ...

  10. #10

Posting Permissions

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