Browse Source

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 years ago
parent
commit
f06b07d57f
1 changed files with 4 additions and 0 deletions
  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) {