1. #1
    Ext JS Premium Member dtex-lab's Avatar
    Join Date
    Sep 2009
    Location
    Italy
    Posts
    341
    Vote Rating
    1
    dtex-lab is on a distinguished road

      1  

    Question AllowBlank false and Hidden true - Form Submit

    AllowBlank false and Hidden true - Form Submit


    Hi

    If I have a field with allowBlank : false and hidden : true, I cannot submit the form if this field is empty.

    I don't know if this is really a bug or a "ExtJS behaviour"...
    From my point of view the "hidden" setting should wins again allowBlank because there is not way for the user to set a value to it.

    I have this case because I have dinamyc forms...

    This is a test case:

    Code:
    <html>
    <head>
    <meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
    <link rel="stylesheet" type="text/css" href="lib/extjs/resources/css/ext-all.css" />
    <script type="text/javascript" src="lib/extjs/adapter/ext/ext-base-debug.js"></script>
    <script type="text/javascript" src="lib/extjs/ext-all-debug.js"></script>
    <script>
    function handleSubmittedFormFailure(aForm, aAction) {
        switch (aAction.failureType) {
        case Ext.form.Action.CLIENT_INVALID:
            Ext.Msg.alert("CLIENT_INVALID");
            break;
        case Ext.form.Action.CONNECT_FAILURE:
            Ext.Msg.alert("CONNECT_FAILURE");
            break;
        case Ext.form.Action.SERVER_INVALID:
            Ext.Msg.alert("SERVER_INVALID", aAction.result.msg);
        }
    }
    Ext.onReady(function () {
        var vViewport = new Ext.Viewport({
            layout: 'border',
            items: [{
                id: 'myform',
                xtype: 'form',
                title: 'Test ItemSelector',
                region: 'center',
                autoHeight: true,
                layout: 'form',
                items: [{
                    xtype: 'textfield',
                    fieldLabel: 'visible fiels',
                    id: "field1",
                    name: "field1",
                    allowBlank: false,
                    hidden: false,
                    hideLabel: false,
                    msgTarget: 'side'
                },
                {
                    xtype: 'textfield',
                    fieldLabel: 'hidden field',
                    id: "field2",
                    name: "field2",
                    allowBlank: false,
                    hidden: true,
                    hideLabel: true,
                    msgTarget: 'side'
                }],
                buttons: [{
                    text: 'Submit',
                    handler: function () {
                        // used to check the error field - Begin
                        Ext.getCmp('myform').getForm().items.each(
                        function (f) {
                            if (!f.isValid()) alert(f.id);
                        });
                        // used to check the error field - End
                        Ext.getCmp('myform').getForm().submit({
                            clientValidation: true,
                            url: 'TestSubmiForm.html',
                            failure: handleSubmittedFormFailure
                        });
                    }
                }]
            }
            ]
        });
    })
    </script>
    </head>
    </body>
    </body>
    </html>
    I believe that the isValid function should bypass not only disabled field but also hidden field...

    e.g.
    Code:
    isValid: function (preventMark) { if (this.disabled || this.hidden) { return true; } ...
    What think ExtJS Team about it ?

    thanks
    Bye
    we make IT work for you

  2. #2
    Ext JS Premium Member dtex-lab's Avatar
    Join Date
    Sep 2009
    Location
    Italy
    Posts
    341
    Vote Rating
    1
    dtex-lab is on a distinguished road

      0  

    Default


    Hi
    Can ExtJS Team tell me if this is considered a bug ? or that you think about it..
    thanks
    we make IT work for you

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

      0  

    Default


    I think you have your title the wrong way round. Confused me for a while.

    Yes, it might seem strange, but technically it's correct.

    The field has allowBlank: false, and so the form is invalid.

    You do not want invalid fields to be submitted to the server.

    I can see a case for a disableOnHide: true config for Fields which would be useful in your case.

  4. #4
    Ext JS Premium Member dtex-lab's Avatar
    Join Date
    Sep 2009
    Location
    Italy
    Posts
    341
    Vote Rating
    1
    dtex-lab is on a distinguished road

      0  

    Default


    Ty Animal.. and sorry.. I make a mistake on the title.. I fix it now...

    I believe (in my cases...) I cannot use

    disableOnHide: true

    because disabled field are not submitted on the server (when the I submit the form).
    I need to submit also field value..

    I should set disableOnHide: true only when field are Hidden (but this state can be changed dinamically...) and mandatory (allowBlank : false) but only if value is not set...

    Too many combination.. cases....I prefer to override Ext.form.Field function...

    Code:
    Ext.override(Ext.form.Field, {
        isValid: function (preventMark) {
            if (this.disabled || this.hidden) return true;
            var restore = this.preventMark;
            this.preventMark = preventMark === true;
            var v = this.validateValue(this.processValue(this.getRawValue()));
            this.preventMark = restore;
            return v;
        },
        validate: function () {
            if (this.disabled || this.hidden || this.validateValue(this.processValue(this.getRawValue()))) {
                this.clearInvalid();
                return true;
            }
            return false;
        }
    });
    thanks
    we make IT work for you

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

      0  

    Default


    So you have allowBlank: false, but you actually want to allow blank? I'm not getting the idea.

  6. #6
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,251
    Vote Rating
    73
    Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold

      0  

    Default


    I assume the OP has a setup that shows/hides certain fields based on context or the values of other fields. If the fields are hidden they are not applicable and should not be validated.

    The only strange thing is that the OP still wants these hidden fields to be submitted. If I had written the server software I would have programmed it so that fields that are not applicable wouldn't need to be submitted. In that case, simply disabling the fields would have worked.

Thread Participants: 2

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar