fixes #5438, multiple binding with alias

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7632 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
gwoo 2008-09-19 15:27:43 +00:00
parent 4f5a51d79d
commit 931d996d90

View file

@ -593,7 +593,7 @@ class Model extends Overloadable {
$className = $assoc;
}
if (!isset($this->{$assoc})) {
if (!isset($this->{$assoc}) || $this->{$assoc}->name !== $className) {
$model = array('class' => $className, 'alias' => $assoc);
if (PHP5) {
$this->{$assoc} = ClassRegistry::init($model);
@ -1326,7 +1326,7 @@ class Model extends Overloadable {
if (!$currentValidates = $this->__save($this, $record, $options)) {
$validationErrors[$key] = $this->validationErrors;
}
if ($options['validate'] === 'only' || $options['validate'] === 'first') {
$validating = true;
if ($options['atomic']) {
@ -1338,7 +1338,7 @@ class Model extends Overloadable {
$validating = false;
$validates = $currentValidates;
}
if (!$options['atomic']) {
$return[] = $validates;
} elseif (!$validates && !$validating) {
@ -2234,7 +2234,7 @@ class Model extends Overloadable {
!is_numeric($data[$fieldName])) && $validator['allowEmpty'] === false
)
);
if ($required) {
$this->invalidate($fieldName, $message);
if ($validator['last']) {