Skip to content

Commit

Permalink
Bug shogodev#217: Исправлен баг обновления привязок модификаций
Browse files Browse the repository at this point in the history
  • Loading branch information
FajeSu committed Mar 25, 2017
1 parent 2309baa commit 79c0750
Showing 1 changed file with 22 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,16 @@ public function beforeSave($event)
{
$this->owner->detachEventHandler('onAfterSave', array(Yii::app()->controller, 'saveProductAssignment'));

$model = BProductAssignment::model();

$assignments = array();
foreach($model->getFields() as $field)
{
$attribute = $field->name;
$assignments[$attribute] = $this->getParentModel()->{$attribute};
if( $this->owner->isNewRecord ) {
$this->owner->getEventHandlers('onAfterSave')->insertAt(1, array($this, 'saveModificationAssignment'));
}
}
}

$model->saveAssignments($this->owner, $assignments);
public function afterSave($event)
{
foreach($this->getModifications() as $modification) {
$modification->saveModificationAssignment();
}
}

Expand Down Expand Up @@ -140,6 +140,20 @@ private function attachRelations()
));
}

protected function saveModificationAssignment()
{
$model = BProductAssignment::model();

$assignments = array();
foreach($model->getFields() as $field)
{
$attribute = $field->name;
$assignments[$attribute] = $this->getParentModel()->{$attribute};
}

$model->saveAssignments($this->owner, $assignments);
}

protected function onAfterRenderTableRow(CEvent $event)
{
if( empty($this->owner->modifications) || Yii::app()->controller->popup)
Expand Down

0 comments on commit 79c0750

Please sign in to comment.