ardent icon indicating copy to clipboard operation
ardent copied to clipboard

Updating nullable values

Open edtownend opened this issue 10 years ago • 1 comments

I've got some nullable boolean fields, so that the value can be true, false, or not defined. I'm setting/updating them using a select field with values of '', 0 and 1.

When I update an object, I of course have to explicitly set any null properties otherwise they won't be updated. Is there a way to make this work with fill() or auto-hydration?

Thanks!

edtownend avatar Apr 17 '14 09:04 edtownend

Fillable will assign anything which is passed. Because models aren't aware of the underlying database you can't set a field to null if it's not defined. Your best bet would be to use a beforeSave filter to nullify anything which isn't defined.

sjdaws avatar May 02 '14 14:05 sjdaws