Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Include models in cakePHP components

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 374
    Comment on it

    Cake models are not available in components. So we need to include them manually. There are lot of ways but I found following very easy:

    Just include construct class in your component class and add all required models there:

    1. public function __construct() {
    2. $uses = array('User', 'Profile');
    3. foreach ($uses as $model) {
    4. $this->$model = ClassRegistry::init($model);
    5. }
    6. }

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Reset Password
Fill out the form below and reset your password: