Kek PHP veri doğrulama için sadece belirli doğrulama kümesi nasıl kullanılır?

0 Cevap php

Ben benim kullanıcı modeli verileri doğrulamak için çalışıyordu ve ben bu sorunun üzerine geldi.

I $ doğrulamak değişken depolanan aşağıdaki doğrulama kuralları, söylüyorlar:

var $validate=array(
        "username" => array(
            "usernameCheckForRegister" => array(
                "rule" => ..., 
                "message" => ...
            ),
            "usernameCheckForLogin" => array(
                "rule" => ...,
                "message" => ...
            )
        ),
        //rules for other fields
    );

In the UsersController controller, I have two actions: register() and login(). The problem is, how do I validate the username field in the register() action using ONLY the usernameCheckForRegister rule, and how do I validate the username field in the login() action, using the other rule, usernameCheckForLogin? Is there any behaviour or method in CakePHP which allows me to choose which set of rules to apply to a form field when validating?

Yardımlarınız için şimdiden teşekkür ederiz!

0 Cevap