/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = ServicesModel::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public static function model($className = __CLASS__) { return parent::model($className); }
<?php $form = $this->beginWidget('CActiveForm', array('id' => 'services-model-form', 'enableAjaxValidation' => false, 'htmlOptions' => array('enctype' => 'multipart/form-data'))); ?> <p class="note">Fields with <span class="required">*</span> are required.</p> <?php echo $form->errorSummary($model); ?> <div class="thumbnail"> <input type="hidden" id="thumb_hidden_id"> <div class="row"> <label class="control-label">?nh</label> <div style="position: relative; width: 360px; height: 210px;left: 125px;"> <img class="thumb-slider-services" id="thumb-change" src="<?php echo ServicesModel::model()->getCoverUrl($model->id); ?> "> <label class="thumb-slider-change-text" for="clip_thumbnail">Upload ?nh</label> <input class="hidden" type="file" name="clip_thumbnail" id="clip_thumbnail" value="image" onchange="onFileSelected(event);"/> </div> </div> <div class="row"> <?php echo $form->labelEx($model, 'name'); ?> <?php echo $form->textField($model, 'name', array('size' => 60, 'maxlength' => 255, 'class' => 'txtchange')); ?> <?php echo $form->error($model, 'name');
public function actionIndex() { $content = HtmlModel::model()->findbyPk(2)->content; $services = ServicesModel::model()->getByHome(); $this->render("index", compact('content', 'services')); }