in the view :
<?php
if(! empty($message)) {
echo "<div class=\"success\">".$message."</div>";
}
if($form->isFieldError('Model_Name.field_name')) {
e($form->error ('Model_Name.field_name',
null,
array(
'class' => 'failure')));
}
?>
in the model you can use this.
var $validate = array(
'email' => array(
'rule1' => array(
'rule' => 'notEmpty',
'required' => true,
'allowEmpty' => false,
'message' => 'Please enter a value for the Email field',
'last' => true),
'rule2' => array(
'rule' => 'email',
'message' => 'Please enter a proper Email Id'
),
'unique' => array(
'rule' => array('checkUnique', 'email'),
'message' => 'A user with this email address already exists, please try again.'
)),
'password' => array(
'notempty' => array(
'rule' => 'notEmpty',
'required' => true,
'allowEmpty' => false,
'message' => 'Confirm Password cannot be empty',
'last' => true
),
);
function checkUnique ($data, $fieldName) {
$valid = false;
if ( isset($fieldName) && $this->hasField($fieldName)) {
$valid = $this->isUnique(array($fieldName => $data));
}
return $valid;
}
good luck..
On Thu, Jul 29, 2010 at 10:22 PM, euromark <dereuromark@googlemail.com> wrote:
you might wanna "re-read" Tilen Majerle's answer...
> > > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp others
On 29 Jul., 18:25, CakeMan <narula.vi...@gmail.com> wrote:
> Well, Validations are working perfectly (giving error message) except
> that error in 2571 line with this "NonEmpty" ??? Strange ??
>
> On Jul 29, 1:12 pm, Tilen Majerle <tilen.maje...@gmail.com> wrote:
>
>
>
> > yes, u have it....it is not "NonEmpty" but is "notEmpty" xD
> > --
> > LP,
> > Tilen Majerlehttp://majerle.eu
>
> > 2010/7/29 CakeMan <narula.vi...@gmail.com>
>
> > > Hi,
>
> > > Is there any problem with this Validation array in my model :
>
> > > var $validate=array
> > > (
> > > 'email'=> array
> > > (
>
> > > 'rule'=>'NonEmpty',
>
> > > 'message'=>'Please provide valid Email.'
> > > ),
> > > 'password'=> array
> > > (
>
> > > 'rule' =>'NonEmpty',
>
> > > 'message'=>'Please provide Password.'
> > > )
> > > );
>
> > > it is giving me error as below :-
> > > Warning (2): preg_match() [function.preg-match]: Delimiter must not be
> > > alphanumeric or backslash [CORE\cake\libs\model\model.php, line 2571]
>
> > > I am using Cake1.3
>
> > > Please help
>
> > > Thanks
>
> > > with their CakePHP related questions.> > > cake-php+unsubscribe@googlegroups.com<cake-php%2Bunsubscribe@googlegroups.c om>For more options, visit this group at
>
> > > 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
> > >http://groups.google.com/group/cake-php?hl=en
Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
--
Master Ram.
Founder n Director of rgPlanets Pvt. Ltd.
Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
No comments:
Post a Comment