Пример #1
0
 public function actionGetSubcat($id)
 {
     $countSubcats = Subcategory::find()->where(['category_id' => $id])->count();
     $subcats = Subcategory::find()->where(['category_id' => $id])->orderBy('id ASC')->all();
     if ($countSubcats > 0) {
         foreach ($subcats as $subcat) {
             echo "<option value='" . $subcat->id . "'>" . $subcat->name . "</option>";
         }
     } else {
         echo "<option>-</option>";
     }
     //        echo Json::encode(['output'=>'', 'selected'=>'']);
 }
Пример #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Subcategory::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10]]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'category_id' => $this->category_id, 'status' => $this->status]);
     $query->andFilterWhere(['like', 'title', $this->title]);
     return $dataProvider;
 }
Пример #3
0
});
JS;
$this->registerJs($script, View::POS_END);
?>

<div class="product-form">

    <?php 
$form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]);
?>
    <?php 
echo $form->field($model, 'auction')->dropDownList(['YES' => 'SI', 'NO' => 'NO'], ['prompt' => '¿Producto como subasta?']);
?>

    <?php 
echo $form->field($model, 'subcategory_id')->DropDownList(ArrayHelper::map(Subcategory::find()->all(), 'id', 'name'), ['prompt' => 'Selecciona una subcategoría.']);
?>

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

    <?php 
echo $form->field($model, 'description')->textarea(['rows' => 6]);
?>

    <?php 
echo $form->field($model, 'stock')->textInput();
?>

    <?php 
 /**
  * Lists all Subcategory models.
  * @return mixed
  */
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => Subcategory::find()]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }