I'm really confused with this - can't get even the simplest examples
working.
I set a test case like this:
<?php
//app/model/Contact.php
class Contact extends AppModel
{
var $name = 'Contact';
var $validate = array(
'email' => array(
'rule' => array('email', true),
'message' => 'Please supply a valid email address.'
)
);
}
?>
###########
<?php
// app/controllers/contacts_controller.php
class ContactsController extends AppController {
var $name='Contacts';
var $uses = array('Contact');
var $helpers = array('form');
function add(){
if( !empty( $this->data ) ){
if ($this->Contact->validates()){
echo "yes";
}
if( $this->Contact->save( $this->data ) ){
$lastId = $this->Contact->getLastInsertId();
$this->flash('Your new user has been created.','/c/
contacts/view/'.$lastId );
}
}
}
}
?>
############
<!-- /app/views/contacts/add.thtml -->
<h1>Enter Contact Information</h1>
<form method="post" action="<?php echo $html->url('/contacts/add')?
>">
<?php echo $form->label('Contact.email', "Contact's E-mail"); ?>
<?php echo $form->error('Contact.email'); ?>
<?php echo $form->text('Contact.email', array('size' => '80') ); ?
>
<br />
<?php echo $form->submit('Check validity'); ?>
</form>
When I submit anything, like "####" or "1oi321" or whatever,
everything validates. The e-mail addresses also validate, which is
nice :) but it clearly isn't working at all. What am I missing? Wrong
configuration? My cake version is 1.2.0.7692 RC3.
On Dec 11, 11:38 am, gearvOsh <[EMAIL PROTECTED]> wrote:
> I just finished doing this today, these two links should help:
>
> http://book.cakephp.org/view/125/Data-Validationhttp://groups.google.com/group/cake-php/browse_thread/thread/d5e98df3...
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" 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
-~----------~----~----~----~------~----~------~--~---