Пример #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Brands::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]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
Пример #2
0
use frontend\models\Brands;
use frontend\models\Marketplace;
use frontend\models\watches;
/* @var $this yii\web\View */
/* @var $model frontend\models\Watches */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="watches-form">

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

    <?php 
echo $form->field($model, 'brands_id')->dropDownList(ArrayHelper::map(Brands::find()->all(), 'id', 'name'), ['prompt' => 'select brand', 'onchange' => '
                        $.post("/index.php/watches/lists?id=' . '"+$(this).val(),function(data){
                                    $("select#watches-modelno").html(data);
                        });
              ']);
?>

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

    <?php 
echo $form->field($model, 'marketplace_id')->dropDownList(ArrayHelper::map(marketplace::find()->all(), 'id', 'name'), ['prompt' => 'select marketplace']);
?>

    <?php