0
votes

I have an app that uses Auth component. Logedin members can alter their data as long as I have no validation rules in users model. When I add array $validate in model logedin users cannot submit data to database.

I use one mysql table named users.

In other words this works but I don't have validation in signup view

<?php
class User extends AppModel {
var $name = 'User';
?>

But when I add validation like this:

<?php
class User extends AppModel {
var $name = 'User';
var $validate = array(
  'email' => array(
    'email' => array('rule' => 'email','required'=>true,'message' => 'Enter proper mail')
  )
);
}
?>

validation in signup view works but users in secret area cannot enter data to database.

1
which version u r using? 1.2 or 1.3? is it throwing any error??RSK

1 Answers

1
votes

My guess is: This is happening because you have set required to true.

This enforces the rule that when submitted data of the User model, the email key needs to be set. Therefore, this works in your Sign Up form which obviously has the email key. On the other hand, the form that you're using in the secret area probably does not have an email field.

Just remove the "required" condition from your validation rule:

'email' => array(
    'email' => array(
        'rule' => array('email'),
        'message' => 'Please enter a valid email',
    ),
),

Let me know if this works for you.