Setting a Field to NULL in DataTables Editor PHP 2.2.2 during preEdit

Setting a Field to NULL in DataTables Editor PHP 2.2.2 during preEdit

toni.petrovictoni.petrovic Posts: 8Questions: 4Answers: 0

Dear all,

I'm encountering a challenge with the DataTables Editor PHP library. Specifically, I need to set a field to a NULL MySQL value in certain cases within the ->on('preEdit', ...) function.

My current code looks like this:

->on('preEdit', function (Editor $editor, $id, $values) use ($db) { $editor->field('tablename.columnname')->setValue(null); }

However, upon examining the library’s source code for setValue, it seems that passing null defaults the function to a getter, rather than setting the value to NULL in the database.

Is there an alternative approach or method to explicitly set a field value to NULL within this context?

Thank you and kind regards,
Toni

Sign In or Register to comment.