here's some pr output.
@@@ AutoCodeBehavior @@@
$model->data @ AutoCode::beforeValidate (begin of function)
Note: this is the original data array returned by the view
Array
(
[Order] => Array
(
[customer_id] => 30
[ref] => TTTTT
)
)
$model->data @ AutoCode::beforeValidate (end of function)
Note: the "Code" field is successfully added to model data array
Array
(
[Order] => Array
(
[customer_id] => 30
[ref] => TTTTT
[Code] => 20090609
)
)
@@@ AutoDateBehavior @@@
$model->data @ AutoDate::beforeSave (begin of function)
Note: the $model->data array is equal to the original one, "Code"
field is magically disappeared, maybe Cake passes the original data
array and not the modified one to every behavior?
Array
(
[Order] => Array
(
[customer_id] => 30
[ref] => TTTTT
)
)
$model->data @ AutoDate::beforeSave (end of function)
Note: field "EstimatedDeliveryDate" is successfully added
Array
(
[Order] => Array
(
[customer_id] => 30
[ref] => TTTTT
[EstimatedDeliveryDate] => 2009-06-09
)
)
@@@ Model @@@
$this->data @ model::beforeSave
Note: there's only "EstimatedDeliveryDate" field in data array. It
seems like the first behavior didn't work at all
Array
(
[Order] => Array
(
[customer_id] => 30
[ref] => TTTTT
[EstimatedDeliveryDate] => 2009-06-09
)
)
On 9 Giu, 15:52, Ernesto <[email protected]> wrote:
> here's my code.
>
> i removed all the comments.
>
> class OrderModel extends AppModel {
>
> var $actsAs = array("AutoCode", "AutoDate");
>
> var $validate = array(
> "Code" => array(
> "unique" => array(
> "rule" => "isUnique",
> "allowEmpty" => false,
> "on" => "create"
> )
> ),
> )
>
> }
>
> class AutoCodeBehavior extends ModelBehavior {
>
> function beforeValidate (&$model) {
>
> $model->data[$model->alias]["Code"] = date("Ymd");
>
> return true;
>
> }
>
> }
>
> class AutoDateBehavior extends ModelBehavior {
>
> function beforeSave (&$model) {
>
> $model->data[$model->alias]["EstimatedDeliveryDate"] =
> date("Y-m-d");
>
> return true;
>
> }
>
> }
>
> On 9 Giu, 15:04, Rob Conner <[email protected]> wrote:
>
>
>
> > You probably should paste code, your "in theory" based on code you
> > told us your wrote is correct. But that doesn't solve the problem. So
> > there must be some error in your code.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---