/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id) { $recordSave = false; $this->layout = ''; $model = $this->loadModel($id); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['TransportStations'])) { $model->attributes = $_POST['TransportStations']; if ($model->save()) { LinkTransportStationsToTransportTypes::model()->deleteAll("transportStation=" . $id); if (isset($_POST['TransportStations']['type'])) { $types = $_POST['TransportStations']['type']; foreach ($types as $typeKey => $typeValue) { if ($typeValue == 1) { $user2role = new LinkTransportStationsToTransportTypes(); $user2role->unsetAttributes(); $user2role->transportStation = $id; $user2role->transportType = $typeKey; $user2role->status = 1; $user2role->save(); } } } $recordSave = true; } } $this->render('update', array('model' => $model, 'recordSave' => $recordSave)); }
<?php if ($transportStations) { ?> <div class="info-box nearest-transport-widget"> <div class="inner-padding"> <div class="header">Nearest Transport</div> <?php $count = 0; foreach ($transportStations as $transportStation) { $stationId = $transportStation['id']; $count++; ?> <div class="narrow-info-row first"> <?php $stationTypes = LinkTransportStationsToTransportTypes::model()->findAllByAttributes(['transportStation' => $stationId]); foreach ($stationTypes as $stationType) { echo '<span class="station-icon">'; switch ($stationType->transportType) { case 1: echo CHtml::image(Yii::app()->params['imgUrl'] . "/transportIcons/tube.png", "tube"); break; case 2: echo CHtml::image(Yii::app()->params['imgUrl'] . "/transportIcons/rail.png", "rail"); break; case 3: echo CHtml::image(Yii::app()->params['imgUrl'] . "/transportIcons/dlr.png", "DLR"); break; case 4: echo CHtml::image(Yii::app()->params['imgUrl'] . "/transportIcons/overground.png", "Overground"); break;