Re: Data validation doesn't work

2009-01-09 Thread josnidhin

Finally its working now Thanks guys for all the help..
I just changes the 'user' in the form create to 'User' and now
everythings working fine.

On Jan 9, 12:01 pm, josnidhin  wrote:
> I tried this still not working..If I use scaffolding to test
> everything works fine validation errors shows up.
> When I use my view then the problem arises.
>
> On Jan 8, 2:29 pm, Nature Lover  wrote:
>
> > Hi!
>
> > try by mentioning also the model name while outputting errors, so the
> > view code will become:
>
> > create('user', array('action' => 'signup'));?>
> > 
> >          Signup
> >       >                  echo $form->input('User.users_name',array
> > ("label"=>"Name:"));
> >                  echo $form->error('User.users_name');
>
> >                  echo $form->input('User.users_email',array
> > ("label"=>"Email:"));
> >                 echo $form->error('User.users_email');
>
> >                  echo $form->input('User.users_password',array
> >  ("label"=>"Password:","type"=>"password"));
> >                  echo $form->input('User.password_confirm',array
> > ('label'=>'Password
> >  Confirm:','type'=>'password'));
> >                  echo $form->error('User.users_password');
> >                  echo $form->error('User.password_confirm');
> >          ?>
> > 
> > end("Sign Up");?>
>
> > Thanks!
>
> > On Jan 8, 10:34 am,josnidhin wrote:
>
> > > create('user', array('action' => 'signup'));?>
> > > 
> > >         Signup
> > >      > >                 echo $form->input('users_name',array("label"=>"Name:"));
> > >                 echo $form->error('users_name');
>
> > >                 echo $form->input('users_email',array("label"=>"Email:"));
> > >                 echo $form->error('users_email');
>
> > >                 echo $form->input('users_password',array
> > > ("label"=>"Password:","type"=>"password"));
> > >                 echo 
> > > $form->input('password_confirm',array('label'=>'Password
> > > Confirm:','type'=>'password'));
> > >                 echo $form->error('users_password');
> > >                 echo $form->error('password_confirm');
> > >         ?>
> > > 
> > > end("Sign Up");?>
>
> > > This is how my view looks like. I am still not getting the errors. But
> > > my validation is working as it only inserts into the database when the
> > > data is correct.
>
> > > var $validate = array(
> > >         "users_name" => array("rule" => "alphaNumeric","required" =>
> > > true,"allowEmpty"=>false,"message" => "Alphabets and numbers only"),
> > >         "users_email" => array(
> > >                 "email"=>array("rule"=>"email","message"=>"Invalid email
> > > address","required" => true,"allowEmpty"=>false),
> > >                 "unique"=>array("rule"=>array
> > > ("validateUniqueEmail"),"message"=>"This Email is already in
> > > use","required" => true,"allowEmpty"=>false)),
> > >         "users_password" => array("rule" => array
> > > ("confirmPassword","password"),"required"=>true,"allowEmpty"=>false,"message"
> > > => "Password do not match"),
> > >                 "password_confirm" => array("rule" => 
> > > "alphaNumeric","required" =>
> > > true)
> > > );
>
> > > This is how my validate array in model looks like confirmPassword and
> > > validateUniqueEmail are function that I wrote. I am not able to figure
> > > out why this is happening.
--~--~-~--~~~---~--~~
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: Data validation doesn't work

2009-01-08 Thread josnidhin

I tried this still not working..If I use scaffolding to test
everything works fine validation errors shows up.
When I use my view then the problem arises.

On Jan 8, 2:29 pm, Nature Lover  wrote:
> Hi!
>
> try by mentioning also the model name while outputting errors, so the
> view code will become:
>
> create('user', array('action' => 'signup'));?>
> 
>          Signup
>                        echo $form->input('User.users_name',array
> ("label"=>"Name:"));
>                  echo $form->error('User.users_name');
>
>                  echo $form->input('User.users_email',array
> ("label"=>"Email:"));
>                 echo $form->error('User.users_email');
>
>                  echo $form->input('User.users_password',array
>  ("label"=>"Password:","type"=>"password"));
>                  echo $form->input('User.password_confirm',array
> ('label'=>'Password
>  Confirm:','type'=>'password'));
>                  echo $form->error('User.users_password');
>                  echo $form->error('User.password_confirm');
>          ?>
> 
> end("Sign Up");?>
>
> Thanks!
>
> On Jan 8, 10:34 am,josnidhin wrote:
>
> > create('user', array('action' => 'signup'));?>
> > 
> >         Signup
> >      >                 echo $form->input('users_name',array("label"=>"Name:"));
> >                 echo $form->error('users_name');
>
> >                 echo $form->input('users_email',array("label"=>"Email:"));
> >                 echo $form->error('users_email');
>
> >                 echo $form->input('users_password',array
> > ("label"=>"Password:","type"=>"password"));
> >                 echo 
> > $form->input('password_confirm',array('label'=>'Password
> > Confirm:','type'=>'password'));
> >                 echo $form->error('users_password');
> >                 echo $form->error('password_confirm');
> >         ?>
> > 
> > end("Sign Up");?>
>
> > This is how my view looks like. I am still not getting the errors. But
> > my validation is working as it only inserts into the database when the
> > data is correct.
>
> > var $validate = array(
> >         "users_name" => array("rule" => "alphaNumeric","required" =>
> > true,"allowEmpty"=>false,"message" => "Alphabets and numbers only"),
> >         "users_email" => array(
> >                 "email"=>array("rule"=>"email","message"=>"Invalid email
> > address","required" => true,"allowEmpty"=>false),
> >                 "unique"=>array("rule"=>array
> > ("validateUniqueEmail"),"message"=>"This Email is already in
> > use","required" => true,"allowEmpty"=>false)),
> >         "users_password" => array("rule" => array
> > ("confirmPassword","password"),"required"=>true,"allowEmpty"=>false,"message"
> > => "Password do not match"),
> >                 "password_confirm" => array("rule" => 
> > "alphaNumeric","required" =>
> > true)
> > );
>
> > This is how my validate array in model looks like confirmPassword and
> > validateUniqueEmail are function that I wrote. I am not able to figure
> > out why this is happening.
--~--~-~--~~~---~--~~
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: Data validation doesn't work

2009-01-07 Thread josnidhin

create('user', array('action' => 'signup'));?>

Signup
input('users_name',array("label"=>"Name:"));
echo $form->error('users_name');

echo $form->input('users_email',array("label"=>"Email:"));
echo $form->error('users_email');

echo $form->input('users_password',array
("label"=>"Password:","type"=>"password"));
echo $form->input('password_confirm',array('label'=>'Password
Confirm:','type'=>'password'));
echo $form->error('users_password');
echo $form->error('password_confirm');
?>

end("Sign Up");?>

This is how my view looks like. I am still not getting the errors. But
my validation is working as it only inserts into the database when the
data is correct.

var $validate = array(
"users_name" => array("rule" => "alphaNumeric","required" =>
true,"allowEmpty"=>false,"message" => "Alphabets and numbers only"),
"users_email" => array(
"email"=>array("rule"=>"email","message"=>"Invalid email
address","required" => true,"allowEmpty"=>false),
"unique"=>array("rule"=>array
("validateUniqueEmail"),"message"=>"This Email is already in
use","required" => true,"allowEmpty"=>false)),
"users_password" => array("rule" => array
("confirmPassword","password"),"required"=>true,"allowEmpty"=>false,"message"
=> "Password do not match"),
"password_confirm" => array("rule" => "alphaNumeric","required" 
=>
true)
);

This is how my validate array in model looks like confirmPassword and
validateUniqueEmail are function that I wrote. I am not able to figure
out why this is happening.

On Jan 7, 3:12 pm, Nature Lover  wrote:
> Hi,
>
> @Lucas =>
> For compulsory fields in a form the validation in model will be like:
>
>    var $validate = array(
>                 'field_name' => array(
>                                 'notEmpty' => array(
>                                                 'rule' => 'notEmpty',
>                                                 'message' => 'Required'
>                                         )
>                         )
>        );
>
> Above will make it compulsory for the field to have data when
> submitted.
> 
>
> @josnidhin=>
> The validation error will be shown automatically along the fields if
> you are creating inputs using form helper.
> Otherwise the below code will work:
>
> isFieldError('ModelName.field_name')){e($form->error
> ('ModelName.field_name'));}?>
>
> Have a nice day!
>
> On Jan 7, 11:36 am,josnidhin wrote:
>
> > Hi,
> > I am also experiencing the same problem. I dont know how to get the
> > messages to show in the view when the validation fails.
>
> > On Jan 4, 12:31 am, Lucas  wrote:
>
> > > Hi gearvOsh,
>
> > > Unfortunately nothing happens again :(
> > > I tryed with both options (required = true and notEmpty rule) and
> > > nothing happens.
>
> > > More tips?
>
> > > Thanks!
>
> > > On 29 dez 2008, 23:24, gearvOsh  wrote:
>
> > > > You either need to have:
>
> > > > required = true
>
> > > > Or use the notEmpty rule.
>
> > > >http://book.cakephp.org/view/127/One-Rule-Per-Fieldhttp://book.cakeph...
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Form validation error not being displayed

2009-01-07 Thread josnidhin

Hi,
I was doing a simple signup form. I am not getting the validation
error msg when they occur. If I enter data in the form that will cause
validation error nothing will happen but if the data is valid
according to my validation rules then they are inserted into the
database.
My code is as follows

Model

class User extends AppModel {
var $name = "User";
var $validate = array(
"users_name" => array("rule" => "alphaNumeric","required" =>
true,"allowEmpty"=>false,"message" => "Alphabets and numbers only"),
"users_email" => array(

"email"=>array("rule"=>"email","message"=>"Invalid email
address","required" => true,"allowEmpty"=>false),
"unique"=>array("rule"=>array
("validateUniqueEmail"),"message"=>"This Email is already in
use","required" => true,"allowEmpty"=>false)),
"users_password" => array("rule" => array
("confirmPassword","password"),"required"=>true,"allowEmpty"=>false,"message"
=> "Password do not match"),
"password_confirm" => array("rule" => "alphaNumeric","required" 
=>
true)
);

 function validateUniqueEmail(){
 $error=0;
 $someone = $this->findByUsers_email($this->data['User']
['users_email']);
 if (isset($someone['User']))
 {
$error++;
 }
 return $error==0;
 }

function confirmPassword($data) {
$valid = false;
if ($data['users_password'] == $this->data['User']
['password_confirm']) {
$valid = true;
}
return $valid;
}
}


Controller

class UsersController extends AppController
{
var $name = "Users";
var $helpers = array("Html","Form");
var $components = array('Security');

function beforeFilter(){
$this->set("p1", $this->name);
}

function signup(){
$this->set("p2", __FUNCTION__);
if (!empty($this->data['user'])){
if ($this->User->save($this->data['user'])){
$this->flash(debug($this->data), 
'/users/signup');
}
}
}

View

create('user', array('action' => 'signup'));?>

Signup
input('user.users_name',array("label"=>"Name:"));

echo $form->input('user.users_email',array("label"=>"Email:"));

echo $form->input('user.users_password',array
("label"=>"Password:","type"=>"password"));

echo 
$form->input('user.password_confirm',array('label'=>'Password
Confirm:','type'=>'password'));

?>

end("Sign Up");?>


--~--~-~--~~~---~--~~
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: Data validation doesn't work

2009-01-06 Thread josnidhin

Hi,
I am also experiencing the same problem. I dont know how to get the
messages to show in the view when the validation fails.

On Jan 4, 12:31 am, Lucas  wrote:
> Hi gearvOsh,
>
> Unfortunately nothing happens again :(
> I tryed with both options (required = true and notEmpty rule) and
> nothing happens.
>
> More tips?
>
> Thanks!
>
> On 29 dez 2008, 23:24, gearvOsh  wrote:
>
> > You either need to have:
>
> > required = true
>
> > Or use the notEmpty rule.
>
> >http://book.cakephp.org/view/127/One-Rule-Per-Fieldhttp://book.cakeph...

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---