Here follows my dirty solution I've created:
app_controller.php: function _beforeScaffold($method) { $this->_HABTM_scaffold_preserve($method); return parent::_beforeScaffold($method); } function _HABTM_scaffold_preserve($method){ $model = $this->uses['0']; if ($method == 'edit' && !empty($this->data ) && $model && !empty ($this->{$model}->hasAndBelongsToMany)){ foreach ($this->{$model}->hasAndBelongsToMany as $HABTM_model => $dummy){ if (isset($this->{$model}->hasAndBelongsToMany[$HABTM_model] ['with']) && $this->{$model}->hasAndBelongsToMany[$HABTM_model] ['with']){ $model_id_text = $this->{$model}->hasAndBelongsToMany [$HABTM_model]['foreignKey']; $habtm_id_text = $this->{$model}->hasAndBelongsToMany [$HABTM_model]['associationForeignKey']; $with_model = $this->{$model}->hasAndBelongsToMany[$HABTM_model] ['with']; if (!empty($this->data[$HABTM_model][$HABTM_model])){ $this->log("app_controller.php/_HABTM_scaffold_preserve: Preserving $model => $with_model", LOG_DEBUG); $model_id = $this->data[$model]['id']; foreach ($this->data[$HABTM_model][$HABTM_model] as $k => $habtm_id){ $data = $this->{$model}->{$with_model}->find( 'first', array( 'conditions' => array($model_id_text => $model_id, $habtm_id_text => $habtm_id ), 'contain' => array() )); if ($data && isset($data[$with_model][$habtm_id_text])) $this->data[$HABTM_model][$HABTM_model][$k] = $data [$with_model]; }//foreach }//if }//if }//foreach }//if }//_HABTM_scaffold_preserve --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---