Hello,
In my controller i have two actions, MyProfile and Update.
Some rules are common, while some are unique to each action.
this is how i am trying to seperate the rules
array('password1','CheckCurrentPassword','on'=>'MyProfile' ),
array('EMAIL', 'CheckIfUnique', 'on'=>'Update'),
Somehow, when i specify the 'on' attribute, the control does not enter functions 'CheckCurrentPassword' or 'CheckIfUnique'.
If i take out the on clause, then all seems to work fine, but the validation rules clash for all the actions.
Can anybody tell me if I am doing something wrong ?
thanks
Arvind
Page 1 of 1
Rules for different actions in same model.
#3
Posted 23 October 2009 - 03:01 AM
Arvind, on 23 October 2009 - 02:37 AM, said:
Hello,
In my controller i have two actions, MyProfile and Update.
Some rules are common, while some are unique to each action.
this is how i am trying to seperate the rules
array('password1','CheckCurrentPassword','on'=>'MyProfile' ),
array('EMAIL', 'CheckIfUnique', 'on'=>'Update'),
Somehow, when i specify the 'on' attribute, the control does not enter functions 'CheckCurrentPassword' or 'CheckIfUnique'.
If i take out the on clause, then all seems to work fine, but the validation rules clash for all the actions.
Can anybody tell me if I am doing something wrong ?
thanks
Arvind
In my controller i have two actions, MyProfile and Update.
Some rules are common, while some are unique to each action.
this is how i am trying to seperate the rules
array('password1','CheckCurrentPassword','on'=>'MyProfile' ),
array('EMAIL', 'CheckIfUnique', 'on'=>'Update'),
Somehow, when i specify the 'on' attribute, the control does not enter functions 'CheckCurrentPassword' or 'CheckIfUnique'.
If i take out the on clause, then all seems to work fine, but the validation rules clash for all the actions.
Can anybody tell me if I am doing something wrong ?
thanks
Arvind
the on index is for the scenario name. so you can have 'on'=>'update'
when you instantiate the model like $obj = new NameOfModel();
you then set the secnario in 1.1 like $obj->scenario = 'update';
then the rules where on is set to update will apply along with those where on is not specified.
php:
foreach(array('cat', 'dog', 'cow') as $animal) echo $animal."\n";
python:
[(animal, print(animal)) for animal in ['cat', 'dog', 'cow']]
ruby:
['cat', 'dog', 'cow'].each {|animal| puts animal}
You say Tomato, I say Tomato.
#4
Posted 23 October 2009 - 03:07 AM
jayrulez, on 23 October 2009 - 03:01 AM, said:
the on index is for the scenario name. so you can have 'on'=>'update'
when you instantiate the model like $obj = new NameOfModel();
you then set the secnario in 1.1 like $obj->scenario = 'update';
then the rules where on is set to update will apply along with those where on is not specified.
when you instantiate the model like $obj = new NameOfModel();
you then set the secnario in 1.1 like $obj->scenario = 'update';
then the rules where on is set to update will apply along with those where on is not specified.
Great...that was super fast. Thanks so much.
I specified my scenario in this way.
$model->validate('<myscenario>');
Is this also a correct way of doing it, or, will it be deprecated ?
thanks
Arvind
#5
Posted 23 October 2009 - 10:12 AM
Arvind, on 23 October 2009 - 03:07 AM, said:
Great...that was super fast. Thanks so much.
I specified my scenario in this way.
$model->validate('<myscenario>');
Is this also a correct way of doing it, or, will it be deprecated ?
thanks
Arvind
I specified my scenario in this way.
$model->validate('<myscenario>');
Is this also a correct way of doing it, or, will it be deprecated ?
thanks
Arvind
i think that should work in all versions prior to 1.1a
php:
foreach(array('cat', 'dog', 'cow') as $animal) echo $animal."\n";
python:
[(animal, print(animal)) for animal in ['cat', 'dog', 'cow']]
ruby:
['cat', 'dog', 'cow'].each {|animal| puts animal}
You say Tomato, I say Tomato.
Share this topic:
Page 1 of 1

Help
This topic is locked











