http://cakebaker.42dh.com/2007/01/03/validation-with-cakephp-12/  <<
Assuming that you're working in 1.2, this describes how you can do multiple
validation rules in 1.2. you define the validation in each model. if you
have a custom validation function that you want shared across all models, i
would put it in /app/app_model.php; you'd have to create it like so:

<?php
class AppModel extends Model {
    var $current_action;

    /**
     * Verify that a user-populated field is unique
     *
     * @todo Check to see if this is initial creation or editing of an entry
     * @param string $value
     * @param string $field
     * @return boolean
     */
    function validateUnique($value, $field) {
        return $this->isUnique( array($field => $value) );
    }

}
?>

On 6/20/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>
> Ok one more question.. If i have multiple controllers that i want all
> to use some validation method, where would be the best place to put
> the validation method?
>
> On Jun 17, 5:28 pm, Grant Cox <[EMAIL PROTECTED]> wrote:
> > I would keep the functionality in separate controllers, not bloat your
> > Users one just because you want to access the User model.  To ensure
> > that users cannot view/edit someone elses data you just need to
> > incorporate this into whatever ACL you use.  For our application I
> > have a function in app_model called isUserOwned( $user_id, $row_id ),
> > which just does a lookup to see if the requested row is owned by the
> > passed user id.  This can easily be included in all my controller
> > actions before allowing the request to proceed.
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to