Hi
I have a form for someone to add their email address to a database, it
is displayed on each static page i am using in my pages/ section
e.g. pages/home has a one input form
echo $html->formTag('/subscribers/add');
echo $html->input('Subscriber/email',
array('size' => '40',
'class'=>'email'));
echo $html->tagErrorMsg('Subscriber/email',
'Valid Email is
required.');
echo $html->submit('Sign up');
so in my Subscriber model's controller, I have an add() method that
checks the validation, if it passes I just show a flash page if it
saves, but if the validation fails, I want to show the page the person
came from again and show the error of why the submission failed.
function add() {
if (empty($this->params['data']))
{
//$this->render();
$this->redirect('/pages/home');
}
else
{
if($this->Subscriber->validates($this->params['data']))
{
//ok cool, the stuff is valid
if
($this->Subscriber->save($this->params['data']))
{
$this->flash('Your email has been added to our
database.','/pages/home');
}
}
else
{
$this->redirect('/pages/home');
//populates
tagErrorMsg('Subscriber/email')
$this->Subscriber->invalidate('email');
$this->render();
}
}
It must be quite simple, but I cannot get it to work.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---