/** * 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 = Itemcategory::findOne($id); if ($model === null) { throw new \yii\web\HttpException(404, 'The requested page does not exist.'); } return $model; }
use app\models\Itemcategory; use app\models\Itemunit; use app\models\ItemVatCat; use app\models\Currates; ?> <div class="form"> <?php $form = kartik\form\ActiveForm::begin(['id' => 'item-form', 'options' => array('enctype' => 'multipart/form-data')]); ?> <?php $temp = ArrayHelper::map(Item::find()->asArray()->all(), 'id', 'name'); $temp[0] = Yii::t('app', 'None'); $cat = ArrayHelper::map(Itemcategory::find()->asArray()->all(), 'id', 'name'); $units = ArrayHelper::map(Itemunit::find()->asArray()->all(), 'id', 'name'); ?> <div class="row"> <?php echo $form->errorSummary($model); ?> </div> <div class="row"> <div class="col-md-4 col-sm-6"> <?php TbPanel::begin(array('header' => Yii::t('app', "Item General Details"))); ?> <?php echo $form->field($model, 'name'); ?>