I had a similar problem.  If you read the API entry for the create()
function, you'll see that it says it "Initializes the model for
writing a new record, loading the default values for those fields that
are not defined in $data."  So any default conditions you set in your
DB fields are auto-loaded into the Model's data variable.  I think
saveField then sees these entries and includes them in the save
action.  Why it does this, I'm not sure.

So yeah, you probably shouldn't use it before saveField.

If you want to be safe, you can wipe out the Model's data array before
using saveField, and then set the ID:

$this->ModelName->data = array();
$this->ModelName->id = $your_record_id;
$this->ModelName->saveField('field',$data);

And that should do it.

Casey

On Mar 5, 9:29 am, bingo <[EMAIL PROTECTED]> wrote:
> hi all,
>
> Can someone explain me when to use create() function.
>
> I believe it make sense to use it when adding a record. But should it
> be used before saving a particular field. It seems if you use create
> function before saveField, CakePHP update all the fields with default
> values. Is this an expected behaviour or some bug ?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to