Editor\Join: Empty child records

Editor\Join: Empty child records

tangerinetangerine Posts: 3,365Questions: 39Answers: 395
edited January 2014 in Editor
How can I avoid adding an "empty" child record when the relevant form field is left blank?

e.g. parent id joined to child id
child table has "id", "extra stuff"
post "create" form with empty "extra stuff" field
result: new child record comprising "id", ""

Replies

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    The problem here is that `''` is valid data, and it might be desirable to actually had that in the database. So I think the only way would be to yo check the value and dynamically set the `set()` method:

    [code]
    ->set( isset($_POST['data']) && $_POST['data']['myData'] ? true : false )
    [/code]

    Or something to that effect :-).

    Allan
This discussion has been closed.