I'm using the validation URL I posted successfully in my enterprise
applications.
It works well with every aspect of Cake1.2 model error handling out of the
box.

Its true it might not be the 100% official way of doing it, nor close to the
1.2 syntax, but it's a good way to do it anyway :)

My guess would be that 1.2.x probably will end up being somewhat close to
the syntax it provides.

Sample code (slightly modified to my own needs, disregard the Danish
messages :))

It looks pretty generic, and that's why I guess 1.2 officially will look
very much like it :)

array(
     'field' => array(
          'someName' => array(
               'method',
               'message',
               'params'
          )
     )
);

    var $validate   = array(
        'user_id'   => array(
            'model' => array(
                'method'    => VALID_HAS_ONE_OF,
                'message'   => 'Ikke en gyldig bruger',
                'params'    => array('model' => 'User')
            )
        ),
        'frontpage' => array(
            'enum'  => array(
                'class'     => 'Cake_Validator',
                'method'    => 'validEnum',
                'message'   => 'Ikke gyldig valgt (Forside)',
                'params'    => array('Y','N')
            )
        ),
        'default'   => array(
            'enum'  => array(
                'class'     => 'Cake_Validator',
                'method'    => 'validEnum',
                'message'   => 'Ikke gyldigt valg (Default)'
            )
        ),
        'active'    => array(
            'enum'  => array(
                'class'     => 'Cake_Validator',
                'method'    => 'validEnum',
                'message'   => 'Ikke gyldigt valg (Aktiv)'
            )
        ),
        'title' => array(
            'required'  => array(
                'method'    => VALID_NOT_EMPTY,
                'message'   => 'Du skal angive en titel'
            )
        ),
        'slug' => array(
            'required'  => array(
                'method'    => VALID_NOT_EMPTY,
                'message'   => 'Du skal angive en SLUG'
            ),
            'unique'    => array(
                'method'    => VALID_UNIQUE,
                'message'   => 'Denne SLUG er allerede brugt'
            )
        )
    );

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of Dr. Tarique Sani
Sent: 12. april 2007 14:57
To: [EMAIL PROTECTED]
Subject: Re: Cake 1.2 - Data Validation - Multiple rules per field
[hack/solution]


On 4/12/07, Christian Winther [Cwi.dk] <[EMAIL PROTECTED]> wrote:
>
> Any reason why you didn't use http://bakery.cakephp.org/articles/view/55 ?
>
Appears to be too complex and too different from what is already there
in 1.2 and most likely will not work with the new $form->input()
either

Like I noted at the bottom of my page - what I wrote is still 95% cake
original code to be used till cake has something similar.

Cheers
Tarique

-- 
=============================================================
PHP for E-Biz: http://sanisoft.com
Cheesecake-Photoblog needs you!: http://cheesecake-photoblog.org
=============================================================



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