Skip to content

Instantly share code, notes, and snippets.

@violetyk
Created October 17, 2011 09:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save violetyk/1292318 to your computer and use it in GitHub Desktop.
Save violetyk/1292318 to your computer and use it in GitHub Desktop.
[cakephp]パスワード確認入力のバリデーション
<?php
class AppModel extends Model {
function equaltofield($check,$otherfield) {
$fname = '';
foreach ($check as $key => $value){
$fname = $key;
break;
}
return $this->data[$this->name][$otherfield] === $this->data[$this->name][$fname];
}
}
// 使い方
var $validate = array(
// パスワード(確認)
'password_confirm' => array(
'rule' => array('equaltofield', 'tmp_password'),
'message' => '上で入力されたパスワードと違います。',
),
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment