Hi,
my database table has a column "size" of type integer (nullable).
When I save into this table from chronoforms and the optional field "size" is filled with an integer, everything works fine. If the field "size" is left blank, the database won't accept the empty string for this column. To handle this, I added a PHP action before the save_data:
if (empty($this->data['size'])) {
$this->data['size'] = null;
}
In the debugger, I can see the result, as in the data-Array: [size] => NULL
But the SQL-Update is nevertheless using an empty string instead of the NULL-Value:
[sql] => UPDATE `product` SET `product` = 'Test Product', `size` = '', `price` = '1.00' WHERE product_id='427090'
How can I handle it to write Null-Values to the DB under some conditions?