Another way to do it is by triggering a method in your model from your
function, like so:
Controller
<?php
class UsersController extends AppController
{
function join()
{
if(empty($this->data))
{
}
else
{
$this->cleanUpFields();
// make sure no one has this email address
$count = $this->User->findCount(array('email' =>
$this->data['User']
['email']));
if($count)
{
$this->User->invalidate('emailtaken'); ####
notice the emailtaken
key ###
$this->Session->setFlash('Um... something
happened. Check
below.');
}
else
{
... create the user stuff here
}
}
}
}
?>
The View
<div class="row">
<div class="field">
<?php echo
$form->labelTag('User/email', 'Email Address');?>
<span><?php echo
$html->input('User/email',
array('class'=>'text2'));?></span>
<?php echo
$html->tagErrorMsg('User/email', 'Please enter your
Email Address.');?>
<?php echo
$html->tagErrorMsg('User/emailtaken', 'This email
address already exists.');?> <!-- This will be displayed -->
</div>
</div>
The $this->Model->invalidate('field'); will trigger the $html-
>tagErrorMsg() with the same name as the 'field' given to the
invalidate() method.
Hope this helps.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" 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=en
-~----------~----~----~----~------~----~------~--~---