/** * 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 findModel($id) { $model = Itemunit::findOne($id); if ($model === null) { throw new \yii\web\HttpException(404, 'The requested page does not exist.'); } return $model; }
echo $i; ?> -line" name="Docdetails[<?php echo $i; ?> ][line]" type="hidden" value="<?php echo $model->line; ?> " /> <?php if ($model->item_id == '') { $model->item_id = 0; } $items = ArrayHelper::map(\app\models\Item::find()->All(), 'id', 'name'); $itemunit = ArrayHelper::map(\app\models\Itemunit::find()->All(), 'id', 'name'); $currency = ArrayHelper::map(\app\models\Currates::GetRateList(), 'currency_id', 'name'); //$temp = \yii\helpers\ArrayHelper::map(Item::find()->All(), 'id', 'name'); //$temp[0] = Yii::t('app', 'None'); echo $form->field($model, "[{$i}]item_id")->dropDownList($items); //select2/$temp ?> </td> <td> <?php //echo $form->field($model, "[$i]name"); ?>
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'); ?> <?php
public function getItemUnit() { return $this->hasOne(Itemunit::className(), array('id' => 'unit_id')); }