Cactiverecord NULL save()

Hi,

I’m trying to save a NULL record but it always saves a ‘0’

my CListData generate something like:


...

<option value="" selected="selected">[ROOT]</option>

...

My db field is already set to NULL.

The array passed to Clistdata contains array(‘id’=>NULL)

I also tried array(‘id’=>‘NULL’) or array(‘id’=>’’) but I always get a 0 stored.

Why ?

add at the beggining of your validation rules in model:




array( 'nullableAttributeName', 'default', 'setOnEmpty'=>true, 'value'=>null ),



I just found how to.

I need to remove the attribute if i want to have a NULL stored in the database like this :


if($model->save(true,array('name')))

Here I save only the "name" attribute, other attributes were removed