Editor submitting field that has no changed values

Editor submitting field that has no changed values

stephanbstephanb Posts: 36Questions: 11Answers: 0
edited February 2021 in Free community support

I have an Editor issue. I setup a Datatable object and am using in-line edits using this snippet:

    $('#PackageTable').on('click', 'tbody td', function (e) {
        editor.inline(this, {
            onBlur: 'submit'
        });
    });

Here is my Editor setup:

    var csrftoken = getCookie('csrftoken');
    var editor = new $.fn.dataTable.Editor( {
        ajax: {
            url: '/data/packages',
            dataSrc: '',
            headers: {'X-CSRFToken': '{{ csrf_token }}'},
        },
        table: "#PackageTable",
        idSrc:  'pk',
        fields: [
            { name: 'pk' },
            { name: 'fields.friendly_name' },
            { name: 'fields.assessment_type' },
            { name: 'fields.assessment_stage' },
            { name: 'fields.priority' },
            { name: 'fields.validated_supporting_event', type: 'text' },
            { name: 'fields.need_by_date', type: 'datetime' },
            { name: 'fields.scheduled_submission_date', type: 'datetime' },
            { name: 'fields.fpm' },// type: "select" },
            { name: 'fields.asm' },
            { name: 'fields.fisse' }

        ]
     });

Here is one Ajax object to give you the format of the data that loads into the table:

[{"model": "CAsPr_Web.caspradminview", "pk": 230, "fields": {"friendly_name": "iBus Migration", "assessment_type": "1D_C", "assessment_stage": "On Hold", "priority": 1, "validated_supporting_event": true, "need_by_date": "2021-02-28", "scheduled_submission_date": "2021-01-19", "fpm": "xxxx xxxxx", "asm": "xxx xxxxxxxxxxxx", "fisse": null}}

When watching the POST to /data/packages, I see my change but Editor always also adds the validated_supporting_event field which I have never touched:

('data[230][fields][friendly_name]', 'iBus Migrationqqqqq')
('data[230][fields][validated_supporting_event]', 'false')
('action', 'edit')
[26/Feb/2021 10:09:48] "POST /data/packages HTTP/1.1" 200 320

Any idea why this is happening?

Answers

  • stephanbstephanb Posts: 36Questions: 11Answers: 0

    So what I found out is interesting. If I change validated_supporting_event from 'text' to 'checkbox', the behavior of being included in the POST stops.
    Why?

  • ndtoan13ndtoan13 Posts: 8Questions: 3Answers: 0
    edited February 2021

    I have similar problem but with select boxes, some (not all) select boxes are being selected without any touch. Still waiting for a solution

This discussion has been closed.