validation æãrule å¥ã«ã¨ã©ã¼ã¡ãã»ã¼ã¸ãåãæ¿ããæ¹æ³
cake1.2ã®è©±
CakePHP ã§ã¯ view 㧠ã¨ã©ã¼ã¡ãã»ã¼ã¸ãæå®ãããã¨ã§
ä»»æã®ã¨ã©ã¼ã¡ãã»ã¼ã¸ãåºåã§ãã¾ãã
{$form->error('name', 'ã¡ãwwwååwwwww')}
rule ãä¸ã¤ã®å ´åãªãããã§ãåé¡ãªãã®ã§ããã
ã¡ã¼ã«ã¢ãã¬ã¹ã® validation ãªã©ã
å
¥åãç¡ãå ´åã¨å
¥åå¤ãä¸é©åãªå ´åã§
éãã¨ã©ã¼ã¡ãã»ã¼ã¸ã表示ãããå ´åã«ã¯
view ã ãã§ã¯å®ç¾ã§ãã¾ããã
ãããªæã«ã¯
model ã® $validate ã以ä¸ã®ããã«æå®ããã° OK ã§ãã
class User extends AppModel { var $name = 'User'; var $validate = array( 'name' => array( 'rule'=>VALID_NOT_EMPTY, 'message'=>'ååãå ¥åãã¦ãã ãã' ), 'email' => array( array( 'rule'=>VALID_EMAIL, 'message'=>'ã¡ã¼ã«ã¢ãã¬ã¹ãä¸é©åã§ãã' ), array( 'rule'=>VALID_NOT_EMPTY, 'message'=>'ã¡ã¼ã«ã¢ãã¬ã¹ãå ¥åãã¦ãã ãã' ), ), 'comment' => array( 'rule'=>VALID_NOT_EMPTY, 'message'=>'ã³ã¡ã³ããå ¥åãã¦ãã ãã' ), ); }
manual ã«ã¯æ¸ãã¦ãªããã©ãã½ã¼ã¹ã«ã¯æ¸ãã¦ããã¾ããã
ããããã¾ããããããããã¨ã