Ticket #618: jcontrollerdaocrud.diff
| File jcontrollerdaocrud.diff, 2.4 kB (added by bastnic, 7 months ago) |
|---|
-
lib/jelix/controllers/jControllerDaoCrud.class.php
old new 253 253 protected function _create($form, $resp, $tpl) { 254 254 255 255 } 256 257 /** 258 * overload this method if you wan to do additionnal things on the dao generated by the 259 * jFormsBase::prepareDaoFromControls method 260 * @param jFormsBase $form the form 261 * @param jDaoRecordBase $form_daorec 262 */ 263 protected function _beforeSaveCreate($form, $form_daorec) { 256 264 265 } 266 257 267 /** 258 268 * save data of a form in a new record 259 269 */ … … 266 276 } 267 277 268 278 if($form->check() && $this->_checkData($form, false)){ 269 $id = $form->saveToDao($this->dao, null, $this->dbProfil); 279 extract($form->prepareDaoFromControls($this->dao,null,$this->dbProfil), 280 EXTR_PREFIX_ALL, "form"); 281 $this->_beforeCreate($form, $form_daorec); 282 $form_dao->insert($form_daorec); 283 $id = $form_daorec->getPk(); 270 284 $form->saveAllFiles($this->uploadsDirectory); 271 285 $rep->action = $this->_getAction('view'); 272 286 $this->_afterCreate($form, $id, $rep); … … 353 367 protected function _editUpdate($form, $resp, $tpl) { 354 368 355 369 } 370 371 /** 372 * overload this method if you wan to do additionnal things on the dao generated by the 373 * jFormsBase::prepareDaoFromControls method 374 * @param jFormsBase $form the form 375 * @param jDaoRecordBase $form_daorec 376 * @param mixed $id the new id of the updated record 377 */ 378 protected function _beforeSaveUpdate($form, $form_daorec, $id) { 356 379 380 } 381 357 382 /** 358 383 * save data of a form in a new record 359 384 */ … … 367 392 } 368 393 369 394 if($form->check() && $this->_checkData($form, true)){ 370 $id = $form->saveToDao($this->dao, null, $this->dbProfil); 395 extract($form->prepareDaoFromControls($this->dao,$id,$this->dbProfil), 396 EXTR_PREFIX_ALL, "form"); 397 $this->_beforeUpdate($form, $form_daorec, $id); 398 $form_dao->update($form_daorec); 371 399 $form->saveAllFiles($this->uploadsDirectory); 372 400 $rep->action = $this->_getAction('view'); 373 401 $this->_afterUpdate($form, $id, $rep);
