Datatables Editor in inline editing mode, sourcing data from joined tables, throws validation error
Datatables Editor in inline editing mode, sourcing data from joined tables, throws validation error
https://datatables.net/examples/editor/inline-editing/join.html
I have a scenario where I got data into Datatables exactly as shown in the example above. The JSON structure is same. However, even in the above working example, if you try editing any column other than the dropdown, you will see a validation error "Input not valid". Same effect is replicated in my code.
Does anybody know why this happens, and what is the fix?
In the above example, after any text column edit, the join.php call returns data that has fieldErrors. Possibly the server side id returning data like that, there is no reason why a 7-8 letter text would not accept the input. It would be helpful to see a example with both - dropdown column and text fields being successfully edited from inline editor. In this example, only dropdown can be edited.
Also, I thought of putting this as comment on the example page itself. Somehow, I don't see any way I can enter comments for this example.
Thanks.
This question has an accepted answers - jump to answer
Answers
Hi,
So the issue in that example (thanks for pointing it out!) is that the
users.sitefield (at the server-side) has arequiredvalidator on it. With inline editing though, by default, only the changed value will be submitted - thus editing anything other than the Location will result in the error you are seeing.There are two fixes possible:
1) Change the validator to remove the
requiredvalidator, and allow the submission to happen without the join value. Instead, you can set it so that the location is not allowed to be empty - this can be done by finding:and replacing with:
2) Have the edit submit all fields, rather than just the one being edited. This can be done with the
submitoption ofform-options- e.g. in yourinline()call do:The benefit to this is that there is no change on the server-side.
I've just committed option 1 to the PHP demo app repo for Editor. I'll deploy it to the site soon.
Regards,
Allan