yii-joblo / multimodelform

Yii extension multimodelform
13 stars 9 forks source link

Composite primary keys problems when rendering the elements #9

Closed maurobender closed 10 years ago

maurobender commented 10 years ago

When rendering the elements the MultiModelForm widget is not handling very well the primary key when it's a composed one. In those cases, when it tries to determine if a model is new or is an update it fails always recognizing it as an update. The error comes from the next lines:

...
} elseif (!empty($this->primaryKey))
{ // existing fieldsets update
    $prefix = 'u__';
    $element->name = '[' . $prefix . '][' . $this->index . ']' . $elemName;
    $doRender = true;
} else
...

As you can see from the code, when the primary key is composed, the value of $this->primaryKey is never empty (because it's an array) and it always recognize it as if the key was already set, even when it's not.

yii-joblo commented 10 years ago

Done.