Nevermind got rid of the errors but it does not validate i never get
an error when i leave the form blank?
index.thtml
<h2>Contact form</h2>
<div>
This is the contact form
</div>
<form method="post" action="<?php echo $html->url('/contact')?>">
<p>
Email:
<?php echo $html->input('Contact/email', array('size' =>
'40'))?>
<?php echo $html->tagErrorMsg('Contact/email', 'Email is
required.') ?>
</p>
<p>
Subject:
<?php echo $html->input('Contact/subject', array('size' =>
'40'))?>
<?php echo $html->tagErrorMsg('Contact/subject', 'Subject is
required.') ?>
</p>
<p>
Body:
<?php echo $html->textarea('Conctact/body',
array('rows'=>'10', 'cols'=>'40')) ?>
<?php echo $html->tagErrorMsg('Contact/body', 'Body is
required.') ?>
</p>
<p>
<?php echo $html->submit('Save') ?>
</p>
</form>
contact_controller.php
<?php
class ContactController extends AppController {
var $name = 'Contact';
// Use swift mailer component and ajax validator
var $components = array('SwiftMailer');
function index()
{
if (!empty($this->data))
{
// mail
}
}
}
?>
models/contact.php
<?php
class Contact extends AppModel {
var $name = 'Contact';
// Let Cake know there is not a DB Table
var $useTable = false;
// Validators used
var $validate = array(
'email' => VALID_EMAIL,
'subject' => VALID_NOT_EMPTY,
'body' => VALID_NOT_EMPTY
);
}
?>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---