Take a look at the CakeBook -
http://book.cakephp.org/view/127/One-Rule-Per-Field
var $validate = array(
'email' => array(
'rule' => array('email', 'isUnique'),
'required' => true,
'allowEmpty' => false,
'on' => 'create',
'message' => 'Your Error Message'
),
'email' => array(
'rule' => array('email', 'isUnique'),
'allowEmpty' => false,
'on' => 'update',
'message' => 'Your Error Message'
),
'url' => array(
'rule' => array('url', 'isUnique'),
'required' => true,
'allowEmpty' => false,
'on' => 'create',
'message' => 'Your Error Message'
),
'url' => array(
'rule' => array('url', 'isUnique'),
'allowEmpty' => false,
'on' => 'update',
'message' => 'Your Error Message'
),
);
On Nov 22, 8:45 pm, Dave <[email protected]> wrote:
> I cant figure out how to do this.
> I have 2 fields, an email and a url, both are required and need to be
> unique when a user wants to update thier info.
>
> If the user is only updating 1 field the other required will fail
> because its required. If they enter in the email field their current
> email because it says required it will come back invalid because its
> no longer unique. Vice versa for the url.
>
> They may only want to change one of the 2 fields information but how
> can you get around this? I dont want them entering in anything thats
> not valid for email / url so i need the validation rules. They are
> both required but how can they edit just 1 field?
>
> Thanks,
>
> Dave
--
You received this message because you are subscribed to the Google Groups
"CakePHP" 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=.