by prettyscripts on 2012-01-18 10:52:00
this is an updated post in reference to a previous post about saving a field to null when no value is entered. thanks to those who left comment, this is the correct (and easier!) way to do it.
add a new rule to the model:
PHP:
protected funcion rules() { | |
return array( | |
.... | |
array('name_of_data_field', 'default', 'setOnEmpty' => true), | |
.... | |
); | |
} |
now the field will be saved as null if data is not entered.