Re: Using dynamic values in model validation

2008-12-25 Thread Adam Royle

Controllers talk to models, not the other way round, so you would need
to call a method in your model from your controllers, passing the
params as necessary.

On Dec 23, 8:52 am, gearvOsh  wrote:
> No not that. In the models beforeValidate() is it possible for me to
> do like $controller->params?
>
> UsersController -> User Model
>
> So in User::beforeValidate() can I get UsersControllers params, is
> basically what im asking?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Using dynamic values in model validation

2008-12-22 Thread gearvOsh

No not that. In the models beforeValidate() is it possible for me to
do like $controller->params?

UsersController -> User Model

So in User::beforeValidate() can I get UsersControllers params, is
basically what im asking?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Using dynamic values in model validation

2008-12-22 Thread Adam Royle

I don't really understand your question... are you asking if you can
see what data is going to be saved from inside the beforeValidate()
method?

If so, look at  $this->data

Cheers,
Adam



On Dec 22, 8:20 pm, gearvOsh  wrote:
> Thanks, also is there a way I can get the parent controller data as
> well?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Using dynamic values in model validation

2008-12-22 Thread gearvOsh

Thanks, also is there a way I can get the parent controller data as
well?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Using dynamic values in model validation

2008-12-21 Thread Adam Royle

When defining class properties you can't use expressions - only data
structures, so you need to populate the $validate array dynamically
inside the model. You can do this in beforeValidate() method in your
model, but be sure to return true.

beforeValidate() {
  $this->validate['fieldName'] = array('between' => array(...
etc ...));
  return true;
}

Cheers,
Adam

On Dec 22, 4:57 pm, gearvOsh  wrote:
> Is there a way to use dynamic variables within the Model validation,
> an example below.
>
> 'between' => array(
>         'rule' => array('between', $passMin, $passMax),
>         'message' => 'Password must be between '. $passMin .' and '. $passMax
> )
>
> I have an array of config settings that I would like to use here, but
> am lost on a way to do this.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Using dynamic values in model validation

2008-12-21 Thread gearvOsh

Is there a way to use dynamic variables within the Model validation,
an example below.

'between' => array(
'rule' => array('between', $passMin, $passMax),
'message' => 'Password must be between '. $passMin .' and '. $passMax
)

I have an array of config settings that I would like to use here, but
am lost on a way to do this.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---