Skip to content

Instantly share code, notes, and snippets.

@allyraza
Created August 13, 2012 07:01
Show Gist options
  • Save allyraza/3337600 to your computer and use it in GitHub Desktop.
Save allyraza/3337600 to your computer and use it in GitHub Desktop.
public function actionUpdate($id)
{
$model=$this->loadModel($id);
$roomInformationModel = $this->loadRoomInformationModel( $_GET['roomInfoId'] );
if( isset($_POST['GuestReservations']) && isset($_POST['RoomInformation']) )
{
$roomInformationModel->attributes = $_POST['RoomInformation'];
$model->attributes = $_POST['GuestReservations'];
if( $roomInformationModel->save() && $model->save() ) {
$this->redirect(array('rooms/view','id'=>$_POST['RoomInformation']['idRooms']));
} else {
// render you partial again with errors if necessary
}
}
}
public function loadRoomInformationModel($id)
{
$model=RoomInformation::model()->findByPk($id);
if($model===null)
throw new CHttpException(404,'The requested page does not exist.');
return $model;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment