/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = ProductAttributeCategory::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $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, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'status' => $this->status]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
 public function getCategory()
 {
     return $this->hasOne(ProductAttributeCategory::className(), ['id' => 'category_id']);
 }
Beispiel #3
0
 public function getAttributeCategory()
 {
     return ProductAttributeCategory::softFind()->select('product_attribute_category.*')->leftJoin(ProductAttribute::tableName(), '`product_attribute_category`.`id` = `product_attribute`.`category_id`')->leftJoin(ProductAttributeAssignment::tableName(), '`product_attribute_assignment`.`attribute_id` = `product_attribute`.`id`')->leftJoin(static::tableName(), '`product`.`id` = `product_attribute_assignment`.`product_id`')->where(['product.id' => $this->id]);
 }
$js = <<<'JS'
$(document).on('click', '#lock-attribute-category', function() {
   $('#product-attribute-category').prop('disabled', $(this).is(':checked')).trigger("chosen:updated"); 
});
JS;
$this->registerJs($js);
?>
                                <div class="checkbox i-checks">
                                    <label>
                                        <input id='lock-attribute-category' type="checkbox" checked><i></i> 锁定/编辑
                                    </label>
                                </div>
                            </div>
                            <div class="col-md-8">
                                <?php 
echo Html::dropDownList('product-attribute-category', $categoryId ? $categoryId : $productAttributeCategory->id, ArrayHelper::map(ProductAttributeCategory::getList(), 'id', 'name'), ['class' => 'chosen-select', 'id' => 'product-attribute-category', 'disabled' => true]);
?>
                            </div>
                        </div>
                    </td>
                </tr>
            </thead>
            <tbody class="container">
                <?php 
foreach ($productAttributeCategory->subAttributes as $index => $productAttribute) {
    ?>
                    <?php 
    if (isset($assignmentProductIdMap[$productAttribute->id]) && $assignmentProductIdMap[$productAttribute->id]) {
        ?>
                        <?php 
        $initialIndex = $index * 100;
 /**
  * Finds the ProductAttributeCategory model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return ProductAttributeCategory the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = ProductAttributeCategory::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Beispiel #6
0
/* @var $model common\models\ProductAttributeCategory */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="product-attribute-category-form">

    <?php 
$form = ActiveForm::begin(['layout' => 'horizontal']);
?>

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

    <?php 
echo $form->field($model, 'status')->dropDownList(ProductAttributeCategory::getStatusLabels());
?>

    <div class="form-group">
        <div class="col-sm-offset-3 col-sm-6">
            <?php 
echo Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-block btn-success' : 'btn btn-block btn-primary']);
?>
        </div>
    </div>

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

</div>
Beispiel #7
0
use common\components\ActiveRecord;
use common\models\ProductAttribute;
use common\models\ProductAttributeCategory;
/* @var $this yii\web\View */
/* @var $model common\models\ProductAttribute */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="product-attribute-form">

    <?php 
$form = ActiveForm::begin(['layout' => 'horizontal']);
?>

    <?php 
echo $form->field($model, 'category_id')->dropDownList(ArrayHelper::map(ProductAttributeCategory::getList(), 'id', 'name'));
?>

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

    <?php 
echo $form->field($model, 'type')->dropDownList(ProductAttribute::getTypeLabels());
?>

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

    <?php