change value of dropdown list via preSubmit

change value of dropdown list via preSubmit

OlanOlan Posts: 41Questions: 11Answers: 1

I'm trying to change a value of a drop down list if another field has some condition. It looks like it is working because I can see the value of the drop down list changing but it is not submitted.
I have the following code:

editor = new $.fn.dataTable.Editor( {
        ajax: "table.marktplanning.php",
        table: "#marktplanning",
        fields: [ 
            {
                "label": "Gebruiker",
                "name": "stand2.User",
                "type": "select"
            },
            {
                "label": "Status",
                "name": "stand2.State",
                "type": "select",
                "ipOpts": [
                    {
                        "label": "Vrij",
                        "value": "free"
                    }
                ]
            }
        ]
    } );
    
   editor.on( 'preSubmit', function ( e, o, action ) {
        if ( o.data.stand2.State === 'free' ) {
                editor.create( false );
                editor.field( 'stand2.User' ).set( 0 );
                editor.submit();
        }
    } );

Hope someone can help me with this. It's driving me nuts :-)

Answers

This discussion has been closed.