1. #1
    Sencha User olivierpons's Avatar
    Join Date
    Dec 2009
    Location
    Aix en Provence,France
    Posts
    116
    Answers
    6
    Vote Rating
    1
    olivierpons is on a distinguished road

      0  

    Default Unanswered: Form and disabled fields: how to send their values anyway?

    Unanswered: Form and disabled fields: how to send their values anyway?


    Hi,

    I've made custom form with some fields.
    When the user checks one checkbox, some other fields are disabled.
    This is just visual, I still need to send all the values.

    The problem is that

    Code:
    form.getValues(false)
    ignores disabled fields.

    But I need to send them anyway. All my server code is based on the fact that I get all the fields. This is for homogeneous reasons (it's like that with all the other stuff with stores: I send all the fields)

    Code:
        onSave: function(){        var form = this.getForm();
            if (form.isValid()) {
                var data = form.getValues(false);
                data.id = this.idPartenaire;
                data = Ext.JSON.encode({ data: data }); 
                this.forEachField(function(){});
                Ext.Ajax.request({
                    headers: {
                        'Content-Type': 'application/json'
                    },  
                    url: '/json/gestion/item/partenaire/',
                    method : 'POST',
                    jsonData : data,
                    params : { 
                        mode: 'update'
                    },  
                    success: function(form, action) {
                        console.log('success');
                    },  
                    failure: function(form, action) {
                        switch (action.failureType) {
                            case Ext.form.action.Action.CLIENT_INVALID:
                                Ext.Msg.alert('Failure', 'blabla');
                                break;
                            case Ext.form.action.Action.CONNECT_FAILURE:
                                Ext.Msg.alert('Failure', 'Ajax failed');
                                break;
                            case Ext.form.action.Action.SERVER_INVALID:
                               Ext.Msg.alert('Failure', action.result.msg);
                       }   
                    }   
                }); 
            }   
        },
    How can I get the values even if they're disabled?

    I'm talking about a generic and proper way, because my workaround is like that:

    Code:
            if (form.isValid()) {
                var data = form.getValues(false);
                var form = this.down('form').form;
                data.livraison = (form.findField('livraison').checked ? 1 : 0);
                data.livraison_delai = form.findField('livraison_delai').value;
    
    
                data = Ext.JSON.encode({ data: data });

  2. #2
    Touch Premium Member
    Join Date
    Jun 2011
    Posts
    1,084
    Answers
    112
    Vote Rating
    95
    Farish is a glorious beacon of light Farish is a glorious beacon of light Farish is a glorious beacon of light Farish is a glorious beacon of light Farish is a glorious beacon of light

      0  

    Default


    what if you use readOnly instead of disabled? you can change a field to read only using the setReadOnly method:

    Code:
    field.setReadOnly(readOnly);
    where readOnly would be a boolean value to set or unset the readOnly state of the field.

  3. #3
    Sencha User olivierpons's Avatar
    Join Date
    Dec 2009
    Location
    Aix en Provence,France
    Posts
    116
    Answers
    6
    Vote Rating
    1
    olivierpons is on a distinguished road

      0  

    Default


    I've tried it, but is doesn't appear "grayed" and the user interaction is "broken" (= the user doesn't know he can't change it).

    And when the user clicks on the other checkbox (the one that 'grays' the other ones), there's a feeling that nothing happened, because there's visually no change (= the use may try to modify some values, and because they became readonly this won't work, which may be very confusing).

  4. #4
    Touch Premium Member
    Join Date
    Jun 2011
    Posts
    1,084
    Answers
    112
    Vote Rating
    95
    Farish is a glorious beacon of light Farish is a glorious beacon of light Farish is a glorious beacon of light Farish is a glorious beacon of light Farish is a glorious beacon of light

      0  

    Default


    but if this works by getting the values of those fields, then you can use it. you can change the css class of the fields to 'x-item-disabled' using addCls method (and removeCls to change it back to normal)

Thread Participants: 1

Tags for this Thread

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