Hello.
i have a model that acts as "AutoCode" and "AutoDate"
both behaviors are adding fields to $model->data but only one is
working. here's my code (see comments for further explanations)
class MyModel extends AppModel {
var $actsAs = array("AutoCode", "AutoDate");
function beforeSave () {
pr($this->data); //there's no "Code" field but "Date" is present
return true;
}
}
class AutoCodeBehavior extends ModelBehavior {
function beforeSave (&$model) {
$model->data[$model->alias]["Code"] =
functionThatGeneratesMyCode();
pr($model->data); //this behavior works regularly. the "Code"
field
is added to $model->data array.
}
}
class AutoDateBehavior extends ModelBehavior {
function beforeSave (&$model) {
pr($model->data); //no more "Code" field is in $model->data
$model->data[$model->alias]["Date"] =
functionThatGeneratesMyDate();
pr($model->data); //this behavior works regularly. the "Date"
field
is added to $model->data array.
}
}
what can i do?
Sry for my bad english
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---