Editor submits fields that have used the default content

Editor submits fields that have used the default content

tstreamtstream Posts: 7Questions: 3Answers: 0

When setting up a datatable i have some columns with the defaultContent set to and empty string because some fields maybe null (cant be avoided).
When i edit any field (inline edit) in a row the Editor submits all the fields that have used the defaultContent (the fields that were null) even if they weren't edited. i am guessing this is because Editor notices null != an empty string thus it thinks it as changed.
how to i tell Editor that these arent changes.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,740Questions: 1Answers: 10,111 Site admin
    Answer ✓

    What's happening here is that Editor does correctly read the null value from the data source for the row, but it reads the values for the form from input elements which does not allow for null as a value. Empty string is the closest.

    Editor sees that difference and thus thinks that the value has changed (this isn't an Oracle db - null !== ''! :)).

    The only way to handle this at the moment is to use a set formatter on the server-side and check if an empty string was submitted. If so write null to the db (isEmpty is the formatter for that).

    It might be possible to use preSubmit to remove items as well, but I've not actually tried that (only just though of it!).

    This is a known weakness of Editor I'm afraid - we need null aware field types!

    Allan

This discussion has been closed.