I am trying to make a contact form but for some reason the textarea
with the message does not give a warning when i put nothing in it?
Does anybody know why? here is my code.

Model 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(
        'name' => VALID_NOT_EMPTY,
        'email' => VALID_EMAIL,
        'subject' => VALID_NOT_EMPTY,
        'message' => VALID_NOT_EMPTY
        );
}
?>

Controller 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 ($this->Contact->validates($this->data))
                {
                        // mail
                }
        }
}
?>

View index.thtml

<h1 class="title">Contact form</h1>
<form method="post" action="<?php echo $html->url('/contact')?>"
class="contact-form">
        <label>Name:</label>
        <?php echo $html->input('Contact/name', array('size' => '40'))?
>
        <?php echo $html->tagErrorMsg('Contact/name', 'Name is
required.') ?>
        <label>Email:</label>
        <?php echo $html->input('Contact/email', array('size' =>
'40'))?>
        <?php echo $html->tagErrorMsg('Contact/email', 'Email is
required.') ?>
        <label>Subject:</label>
        <?php echo $html->input('Contact/subject', array('size' =>
'40'))?>
        <?php echo $html->tagErrorMsg('Contact/subject', 'Subject is
required.') ?>
        <label>Message:</label>
        <?php echo $html->textarea('Conctact/message',
array('rows'=>'10', 'cols'=>'37')) ?>
       <?php echo $html->tagErrorMsg('Contact/message', 'Message is
required.') ?>
        <?php echo $html->submit('Save') ?>
</form>


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to