CodeIgniter Forums
Entity or Model Default null for all Empty fields - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forum-28.html)
+--- Forum: CodeIgniter 4 Discussion (https://forum.codeigniter.com/forum-31.html)
+--- Thread: Entity or Model Default null for all Empty fields (/thread-80259.html)



Entity or Model Default null for all Empty fields - compserlogin - 10-08-2021

I am new to Codeigniter currently trying to learn and building an testing application i have used Model & Entity classes 
how to make default null value for empty fields during insert & update records


RE: Entity or Model Default null for all Empty fields - InsiteFX - 10-09-2021

The database field has to allow null values, if it's set to not null then it will not except a null value.

Set the database field name to null to allow null values then it will except them.


RE: Entity or Model Default null for all Empty fields - ikesela - 10-09-2021

check migration table, set default value and allow null
Code:
[ 'type' => your_type , 'null' => true, 'default' => your_default_value]

or just edit table (example phpmyadmin) to set allow null and set default value