Ejemplo n.º 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = CharacteristicModel::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'idCategory' => $this->idCategory]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'value', $this->value]);
     return $dataProvider;
 }
Ejemplo n.º 2
0
/* @var $model app\models\CharacteristicValueModel */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="characteristic-value-model-form">

    <?php 
$form = ActiveForm::begin();
?>

    <?php 
echo $form->field($model, 'idProduct')->dropDownList(ArrayHelper::map(ProductModel::find()->all(), 'id', 'name'));
?>

    <?php 
echo $form->field($model, 'idCharacteristic')->dropDownList(ArrayHelper::map(CharacteristicModel::find()->all(), 'id', 'name'));
?>

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

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

    <?php 
ActiveForm::end();
?>
Ejemplo n.º 3
0
    <!-- <?php 
echo $form->field($model, 'amountRated')->textInput();
?>
 -->

    <?php 
echo $form->field($model, 'idCategory')->dropDownList(ArrayHelper::map(CategoryModel::find()->all(), 'id', 'name'), ['readonly' => isset($model['idCategory'])]);
?>

    <?php 
if (isset($model['idCategory']) && isset($model['id'])) {
    if (isset($model->idCategory)) {
        $characteristics = CharacteristicModel::find()->where(['idCategory' => $model['idCategory']])->all();
        $category = CategoryModel::find()->where(['id' => $model['idCategory']])->one();
        while ($category['parentId'] != null) {
            $temp = CharacteristicModel::find()->where(['idCategory' => $category['parentId']])->all();
            foreach ($temp as $temp_char) {
                $characteristics[] = $temp_char;
            }
            $category = CategoryModel::find()->where(['id' => $category['parentId']])->one();
        }
    }
    $counter = 0;
    foreach ($characteristics as $characteristic) {
        $char_model = CharacteristicValueModel::find()->where(['idProduct' => $model['id'], 'idCharacteristic' => $characteristic->id])->one();
        if ($char_model == null) {
            $char_model = new CharacteristicValueModel();
            $char_model->idProduct = $model['id'];
            $char_model->idCharacteristic = $characteristic->id;
        }
        echo Html::activeHiddenInput($char_model, "[{$counter}]idProduct");