Hi all,
I'm a newbie at cakePHP, and still at the learning phase.
I was trying to make a user management system with cakephp, where we
can add/edit/delete user. But I am stuck in the validation part. I
hope someone can help me on this.
I have this 'users' table:
=========================
CREATE TABLE `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(255) NOT NULL,
`password` varchar(32) NOT NULL,
`email` varchar(80) NOT NULL,
`name` varchar(255) NOT NULL DEFAULT '',
`designation` varchar(255) DEFAULT NULL,
`role` varchar(30) NOT NULL,
`print_perm` int(1) NOT NULL,
`disabled` int(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
and I have this form to add the user:
=========================
echo $form->create('User');
echo $form->input('username');
echo $form->input('email');
echo $form->input('name');
echo $form->input('designation');
$options=array('admin'=>'Administrator','user'=>'User');
echo $form->label('Role');
echo $form->select('role',$options);
echo $form->label('Password');
echo $form->password('password1');
echo $form->label('Confirm Password');
echo $form->password('password2');
echo "<br>";
echo $form->checkbox('print_perm');
echo "<span class='text-bold'> Can Print?</span><br><br>";
echo $form->input('id', array('type'=>'hidden'));
echo $form->button('Save', array('type' => 'submit'));
echo $form->button('Reset', array('type' => 'reset'));
echo $form->end();
I put this validation on my model:
=========================
var $validate = array(
'username' => array(
'alphaNumeric' => array(
'rule' => 'alphaNumeric',
'message' => 'Alphabets and numbers only'
),
),
'email' => 'email',
'name' => VALID_NOT_EMPTY,
'role' => VALID_NOT_EMPTY,
'password' => VALID_NOT_EMPTY,
);
it is not working for the 'role' and 'password' field. I have
'password1' and 'password2' in the view, while my db field is
'password'. I'm not sure what to do to make this work.
Any help is appreciated. Thank you.
--
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=.