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.petrovic](https://secure.gravatar.com/avatar/46c7d5cad6b6737ac7a9b89827ec53ec/?default=https%3A%2F%2Fvanillicon.com%2F46c7d5cad6b6737ac7a9b89827ec53ec_200.png&rating=g&size=120)
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