Try this:

In the Model:
-------------------

        var $validate = array(
                        'fieldName' => array(
                                'rule' => array('maxLength', '8'),
                                'message' => 'Maximum 8 characters long',
                                'required' => true
                                )
                        );

The View:
---------------

        <?php echo $form->create('ModelName', array('action' => 'add'));?>
                <?php echo $form->input('fieldName');?>
                <?php echo $form->submit('Save');?>
        <?php echo $form->end(); ?>

The Controller:
---------------------

        function add()
        {
                if (!empty($this->data))
                {
                        $this->ModelName->create();
                        $this->ModelName->save($this->data);
                        $this->redirect(array('action' => 'index'));
                }
        }

I hope that helps,

David

On Jan 29, 1:33 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> Can someone post a simple 1.2 beta example of a form w/ validation?  I
> have tried all kinds of examples on various sites, but none work.  I'd
> like to see the view for a simple form, and the corresponding
> controller and model.  If the validation could show an example of
> required and maxLength rules with displaying error messages I would
> really appreciate it.  Thanks.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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