On Feb 23, 1:51 pm, MonkeyGirl <[EMAIL PROTECTED]> wrote:
> Hi.
>
> I'm setting up some attributes that are arrays in inherited classes.
> For example, in /app/app_model.php I have the $validate rules that
> apply to some columns which appear in every table. Similarly, in /app/
> app_controller.php I have some universal $paginate settings such as
> the limit.
>
> Now I'm trying to add to these universally applicable values in the
> arrays with values specific to each model and controller. For example,
> adding rules that are unique to each model and paginate settings
> specific to each controller.
>
> Does anyone here know the official, recommended, CakePHP-approved way
> of adding new values to these existing arrays once they've been
> inherited? I can't use $validate += array(stuff); outside of a method.
> Would putting it in beforeValidate for the model, and a similar line
> in beforeFilter for the controller, achieve what I'm after? I have the
> feeling this technique *might* work, but I'd be doing it in a really
> bad way.
>
> Is there a clean, simple way of doing this? Sorry if it's in the
> documentation. I had a quick look for it, but I'm not really sure what
> to search for.
>
> Thank you,
> Zoe.
You could take a look at the controller constructor and borrow the
same logic.
If you define a constructor in any of your classes DO NOT forget to:
call the parent
define your constructor to accept the same parameters as the parent
and pass them in the parent call
hth,
AD
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" 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
-~----------~----~----~----~------~----~------~--~---