Thursday, January 31, 2013

Re: Using variable from controller in model

Use $this->set('noslug', 1); instead.

On Tuesday, January 29, 2013 12:41:42 PM UTC-2, MetZ wrote:
Hi all.

I am struggling passing a variable to my before save function in my User model.

Controller:
$this->User->read(null, $data['user_id']);
                $this->User->set(array(
                    'noslug' => 1,
                    'TEST' => 'sdfsd'
                ));
        $this->User->save();

Model:

if(empty($this->data[$this->alias]['noslug']) {
  // noslug empty, do somthing cool
} else {
  // noslug not empty, do something else
}


$this->data[$this->alias]['noslug'] = always empty/false

How can I read the "noslug" = 1 in my model?

Thanks for any help on this!
-Tom

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments: