/**
  * Finds the Category model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Category the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Category::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Beispiel #2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCategory()
 {
     return $this->hasOne(Category::className(), ['id' => 'category_id']);
 }
Beispiel #3
0
?>

        <?php 
echo $form->field($modelBook, 'publisher_id')->dropDownList(BookForm::createArrayMap(Publisher::className(), 'id', 'name'));
?>

        <?php 
echo $form->field($modelBook, 'type_id')->dropDownList(BookForm::createArrayMapTranslate(Type::className(), 'id', 'type'));
?>

        <?php 
echo $form->field($modelBook, 'status_id')->dropDownList(BookForm::createArrayMapTranslate(Status::className(), 'id', 'status'));
?>

        <?php 
echo $form->field($modelBook, 'category_id')->dropDownList(BookForm::createArrayMapTranslate(Category::className(), 'id', 'category_name'));
?>

        <?php 
echo $form->field($modelBook, 'library_id')->dropDownList(BookForm::createArrayMap(Library::className(), 'id', 'name'));
?>

        <?php 
echo $form->field($modelBook, 'edition')->textInput();
?>

        <?php 
echo $form->field($modelBook, 'year')->widget(yii\widgets\MaskedInput::classname(), ['mask' => '9999']);
?>

        <div class="form-group">