ソースを参照

Throw an exception if one tries to use the same name for both fields as this is cleary not allowed or good practice.

euromark 11 年 前
コミット
f06b07d57f
1 ファイル変更4 行追加0 行削除
  1. 4 0
      Model/Behavior/PasswordableBehavior.php

+ 4 - 0
Model/Behavior/PasswordableBehavior.php

@@ -249,6 +249,10 @@ class PasswordableBehavior extends ModelBehavior {
 		$formFieldRepeat = $this->settings[$Model->alias]['formFieldRepeat'];
 		$formFieldCurrent = $this->settings[$Model->alias]['formFieldCurrent'];
 
+		if ($formField === $this->settings[$Model->alias]['field']) {
+			throw new CakeException('Invalid setup - the form field must to be different from the model field (' . $this->settings[$Model->alias]['field'] . ').');
+		}
+
 		$rules = $this->_validationRules;
 		foreach ($rules as $field => $fieldRules) {
 			foreach ($fieldRules as $key => $rule) {