Error on preSubmit to DB: Cannot set property 'pending' of undefined
Error on preSubmit to DB: Cannot set property 'pending' of undefined
Hi Everybody,
I cannot update DB from my custom Edit form. I got the error "Cannot set property 'pending' of undefined".
Here's the link to EXAMPLE
https://www.beppebiondi.it/example/
This is the action I am trying to do and where i get the error.
I want to modify example.pending and example.pendingTo on my DB with '0' and 'null' respectively.
editorPending.on( 'preSubmit', function ( e, data, action ) {
if ( action === 'edit' ) {
scelta = editorPending.field( 'example.pending' ).val();
if ( scelta === '1' ) {
data.data.example.pending = 0;
data.data.example.pendingTo = null;
}
else {
alert (scelta);
}
}
} );
See attachments for full code of Javascript and Server Side.
Please, could someone help me? I am going crazy! THANKS!
Giovanni
Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
Replies
This is what I've done and now it seems to go successfully.
Is it right?
Why is "data.data.example.pending = 0;" wrong?
Hi,
Good to hear you've got the solution. The reason you can't just use
data.data.propertyName
is that Editor supports multi-row editing, so the content indata.data
is actually an object - one entry for each row being edited. This approach is used even if there is only one row being edited.Full details of the data submitted available here.
Before multi-row editing was introduced (1.5) then yes, what you had would have worked, but it didn't allow for multi-row editing.
Allan
Thank you very much Allan!
Can I ask you how can I avoid submitting of certain fileds I need to see in the editor but not to update in DB? This data comes from a join and I don't want to update the joined table. Is it possible?