Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82935

Extra field to control another one via dependent() always being sent to server

$
0
0

Hi, I'm using Editor and I have the necessity to add a checkbox that controls the value of an upload field. Here's the behaviour I'm trying to get:
I have an upload field for an image and I want to 'store' if that upload is necessary or not. So I added this field to my editor

{
        label: '',
        name: 'noimg',
        type: "checkbox",
        options: [
            { label: 'No image required', value: 1 }
        ],
        separator: '',
        unselectedValue: 0
}

And through dependent():

editor.dependent('noimg', function (val, data, callback) {
        if (val == 1) {
            editor.field('prodotti.immagine').set(0);
            editor.hide('prodotti.immagine');
        } else {
            if (editor.field('prodotti.immagine').val() == 0) {
                editor.field('prodotti.immagine').set('');
            }
            editor.show('prodotti.immagine');
        }
        callback(true);
    });

I show/hide and set value for the upload field, based on the checkbox status.
The editor is set to 'changed' to submit only changed fields. However, since I added noimg field, every edit ends with noimg data being submitted with 0 value.
Is there an option to prevent a field from being sent to the server? Or am I using the wrong approach to obtain this?
Thank you!


Viewing all articles
Browse latest Browse all 82935

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>