I would like to give the possibility to a user to update his own information directly from his view page. Like we can find on "admin" page with the "advanced search" link, the user would have the possibility to click on link which would collapse an update form with the save button of course.
I speak about the search link cause I tried to use its implementation to do the same with update from on view. However I didn’t succeed… I tried many things, playing with controller… render… forms… _view etc… But, the best thing I get to do is to display the form… but when I tried to save it, nothings happen. does anybody have an idea how to manage it ?
The most simple solution is probably to just invoke your update code from the view action. Here is a rough idea of what I mean:
public function actionView($id) {
if(Yii::app()->request->isPostRequest) $this->actionUpdate($id);
$this->render('view',array( 'model'=>$this->loadModel($id)));
}
I haven’t tested this at all but I’ve used something similar before and it worked well for my situation.
(Also, if speed is a concern you’ll probably want to work around the fact that this will retrieve the record from the DB twice. Because of this, making a separate method for the form post check code may not be a bad idea.)