예제 #1
0
$form = ActiveForm::begin();
?>

    <?php 
echo $form->field($model, 'name')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'parent_id')->dropDownList(ArrayHelper::map(ProductType::find()->asArray()->orderBy('name')->all(), 'id', 'name'), ['prompt' => '']);
?>

    <?php 
echo $form->field($model, 'eAttributes')->widget(Select2::classname(), ['data' => ArrayHelper::map(ProductAttribute::find()->asArray()->orderBy('name')->all(), 'id', 'presentation'), 'options' => ['multiple' => true]]);
?>

    <?php 
echo $form->field($model, 'options')->widget(Select2::classname(), ['data' => ArrayHelper::map(ProductOption::find()->asArray()->orderBy('name')->all(), 'id', 'presentation'), 'options' => ['multiple' => true]]);
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? Module::t('module', 'Create') : Module::t('module', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-primary' : 'btn btn-success']);
?>
    </div>

    <?php 
ActiveForm::end();
?>

</div>
 /**
  * Finds the ProductOption model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return ProductOption the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = ProductOption::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }