1. #1
    Sencha User Katha's Avatar
    Join Date
    Jun 2009
    Posts
    9
    Vote Rating
    0
    Katha is on a distinguished road

      0  

    Question form submit problem

    form submit problem


    Hi,
    i´ve got a problem with my forms. In my js i have many forms, which have all a different id, but when i submit one of this forms, the values of all forms are transfered. this is a problem, because some form items of different forms, which all have an id too, need the same name.
    also my items are sometimes dynamic, so there may be one time item name_0_1 and name_0_2 and next time i only want to send name_0_1.
    hope someone understands what i mean.

    i tried different things i could imagine like form.destroy and form.removeAll, but found no usable solution.

    has anyone an idea, how i can solve this problem?
    perhaps i´m thinking in the wrong way...

    thanks a lot.

  2. #2
    Sencha User Katha's Avatar
    Join Date
    Jun 2009
    Posts
    9
    Vote Rating
    0
    Katha is on a distinguished road

      0  

    Default


    no one any idea? damn. i was so hopefull, that there is somebody who knows what to do.
    so now i´m gonna try on.
    Thanks anyway.

  3. #3
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,499
    Vote Rating
    47
    Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    I don't think anyone reading this thread has a clue what you are on about.

  4. #4
    Sencha User Katha's Avatar
    Join Date
    Jun 2009
    Posts
    9
    Vote Rating
    0
    Katha is on a distinguished road

      0  

    Default


    Ok, thanks. So let me try to explain it a little better. It is hard for me to explain it in german, and even harder in english.
    I´m using a viewport with many tabs inside. In these tabs I have some forms for searching the data.
    Also i have some forms to create and edit my objects like users for example which open in new Ext.Windows.

    The problems start after opening the edit form window and editing an user which has more than one email.
    In my edit form i iterate over the email list and create a field for each emailaddress. These have names like email_0 and email_1.
    If i want to create a new user after this, there is only one field for email named email_0.

    But the values of the edit form seem to be cached anywhere, cause after submitting the create user form I have data values of other forms in my valueMap e.g. of the edit user form with email_1.
    In my Action i iterate over the requested emails too, so users will be created with email_0 and email_1.

    I hope, this is a little more understandable.

  5. #5
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,499
    Vote Rating
    47
    Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    I don't understand. You will have to show some code.

  6. #6
    Sencha User Katha's Avatar
    Join Date
    Jun 2009
    Posts
    9
    Vote Rating
    0
    Katha is on a distinguished road

      0  

    Default


    ok, it may be a little complicated, cause i created my own FormPanel extending the Ext.form.FormPanel. i shortened the code as much as possible.
    this is the code for my form

    Code:
    eu.tv1.form.FormFromValues = function(config){
        this.submitUrl = config.submitUrl;
        this.bodyCfg = {
            tag: 'form',
            cls: this.baseCls + 'x-panel-body',
            method : this.method || 'POST',
            id : this.formId || Ext.id(),
            action:this.submitUrl,
            url:this.submitUrl
        };
        Ext.applyIf(config, {
            title:"Form",
            renderTo:config.target,
            width: config.width,
            listeners:{
                'render':function(f){
                    f.body.set({action: f.submitUrl});
                }
            }
        });
        if(config.submitFunction){
            this.submitFunction = config.submitFunction;
        }
        
        eu.tv1.form.FormFromValues.superclass.constructor.call(this, config);
        
    }
    
    Ext.extend(eu.tv1.form.FormFromValues, Ext.form.FormPanel,{
        
        fields : [],
        submitFunction:null,
        submitUrl:"",
        ajax:true,
        addField:function(config){
            var type = config.type;
            if(type == "string"){
                var field = new Ext.form.TextField({
                    id: config.id,
                    name: config.name,
                    validator: config.validator,
                    value: config.initialValue,
                    fieldLabel: config.title,
                    hideLabel: config.hideTitle,
                    inputType: config.inputType ? config.inputType : "text",
                    itemCls: config.itemClass,
                    style: config.style,
                    labelStyle: config.labelStyle,
                    width: config.width,
                    disabled: config.disabled
                });
                this.add(field);
                this.fields.push(field);
            } //.. other types follow
            this.doLayout();
        },
        getValues:function(){
            var result = {};
            Ext.each(this.fields, function(field){
                var name = field.getName();
                if(field.getGroupValue){
                    result[name] = field.getGroupValue();
                }
                else if(field.getValueInMillis){
                    var val = field.getValue();
                    //window.console.log(val.format('j'));
                    result[name] = field.getValueInMillis();
                }
                else{
                    result[name] = field.getValue();
                }
            }, this);
            return result;
        },
        addSubmitButton:function(config){
            var btn =  new Ext.Button({text:config.title, id:config.id});
            btn.on("click", this.doOnSubmit, this);
            this.add(btn);
            this.doLayout();
        },
        doOnSubmit:function(e){
            if(this.submitFunction != null){
                this.submitFunction(this.getValues());
                return;
            }
            if(this.ajax){
                this.submitByAjax();
            }
            else{
                this.body.dom.submit();
            }
        },
        submitByAjax:function(){
            Ext.Ajax.request({
                url:this.submitUrl,
                params:this.getValues(),
                mehtod:"POST"
            });
        }
    });
    here is my createUser function

    Code:
    function createUser() {
        var url = App.sema.userAdminUrl+'_json_user_create';
        var createUserForm = new eu.tv1.form.FormFromValues({
            submitUrl:url,
            ajax:true,
            width: 500,
            submitFunction: submitCreateUserFormAndCloseWindow,
            id: 'createUserForm',
            title: ''
        });
        createUserForm.addField({
            type:eu.tv1.form.Types.STRING,
            title:"Vorname",
            name:"name",
            id: 'createUserName',
            initialValue: "",
            width: 250
        });
        createUserForm.addField({
            type:eu.tv1.form.Types.STRING,
            title:"Nachname",
            name:"lastname",
            id: 'createUserLastName',
            initialValue: "",
            width: 250
        });
        createUserForm.addField({
            type:eu.tv1.form.Types.STRING,
            title:"E-Mail",
            name:"email_0",
            id: 'createUserEmail_0",
            initialValue: "",
            width: 250
        });
        createUserForm.addField({
            type:eu.tv1.form.Types.STRING,
            name:"login",
            title:"Login",
            id: 'createUserLogin",
            initialValue: "",
            width: 250
        });
        createUserForm.addSubmitButton({
            title:"Speichern"
        });
        var createUserWin = new Ext.Window({
            collapsible:false,
            modal:true,
            title: "Neuen User anlegen",
            layout: 'form',
            id: 'createUserWindow',
            items: createUserForm
        });
        createUserWin.show();    
    }
    and this is the edit user function, where i have the iteration over the email addresses
    Code:
    function editUser(userId) {
        var conn = new Ext.data.Connection();
        conn.request({
            scope:this,
            url: App.sema.userAdminUrl + '_json_user_infos?id='+userId
        });
        conn.on('requestcomplete', function(conn, response, options) {
            var responseData = Ext.util.JSON.decode(response.responseText);
            var url = App.sema.userAdminUrl+'_json_user_edit';
            var editUserForm = new eu.tv1.form.FormFromValues({
                submitUrl:url,
                ajax:true,
                width: 500,
                submitFunction: submitEditUserFormAndCloseWindow,
                id: 'editUserForm',
                title: ''
            });
            editUserForm.addField({
                type:eu.tv1.form.Types.STRING,
                title:"Vorname",
                name:"name",
                id: 'editUserName',
                initialValue: responseData.name,
                width: 250
            });
            editUserForm.addField({
                type:eu.tv1.form.Types.STRING,
                title:"Nachname",
                name:"lastname",
                id: 'editUserLastName',
                initialValue: responseData.lastname,
                width: 250
            });
            var emailList = responseData.emailList;
            if (Ext.isArray(emailList) && emailList.length > 0) {
                for(var i = 0; i < emailList.length; i++) {
                    var email = emailList[i];
                    editUserForm.addField({
                        type:eu.tv1.form.Types.STRING,
                        title:"E-Mail",
                        name:"email_"+i,
                        id: 'editUserEmail_"+i,
                        initialValue: email,
                        width: 250
                    });
                }
            }
            editUserForm.addField({
                type:eu.tv1.form.Types.STRING,
                name:"login",
                title:"Login",
                id: 'editUserLogin",
                initialValue: responseData.login,
                width: 250
            });
            editUserForm.addSubmitButton({
                title:"Speichern"
            });
            var editUserWin = new Ext.Window({
                collapsible:false,
                modal:true,
                title: "User bearbeiten",
                layout: 'form',
                id: 'editUserWindow',
                items: editUserForm
            });
            editUserWin.show();
        });
    }
    and last but not least, this is the submit function i´m using (one of them, they only differ by the form)
    Code:
    function submitEditUserFormAndCloseWindow(valueMap) {
        var form = Ext.getCmp('editUserForm');
        Ext.Ajax.request({
            url:form.submitUrl,
            params:valueMap,
            mehtod:"POST",
            success: function(resp,opt) {
                // ... do something
            },
            failure: function(resp,opt) {
                // ... do something
            }
        });
    }

  7. #7
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,499
    Vote Rating
    47
    Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    This addField thing is pointless!

    Just use add. The whole point of needing doLayout is that it should only be called once. After all items are added. Not for every item added!

    Removing all that stuff will fix your problem. A FormPanel's captive BasicForm encapsulates all Fields that are present in a FormPanel. Use that.

    Don't use subclasses unless you know what you are doing. You were placing all Fields added to every instajce of that class into ONE SHARED ARRAY.

  8. #8
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,499
    Vote Rating
    47
    Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    You should be using Ext 3.

  9. #9
    Sencha User Katha's Avatar
    Join Date
    Jun 2009
    Posts
    9
    Vote Rating
    0
    Katha is on a distinguished road

      0  

    Default


    this is unfortunately not possible now, cause all projects in my company got to be with the same ext version. but we will hopefully update it soon. thanks for your help. i will try. the form class was not my code. i was only told to use it, but i will solve this problem.

  10. #10
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,499
    Vote Rating
    47
    Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    Then you were told by somebody who should not be in a position do do any telling.

Thread Participants: 1

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi