/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Canton::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_cant' => $this->id_cant, 'id_prov' => $this->id_prov]); $query->andFilterWhere(['like', 'nom_cant', $this->nom_cant])->andFilterWhere(['like', 'desc_cant', $this->desc_cant]); return $dataProvider; }
use yii\widgets\ActiveForm; use app\models\Canton; use yii\helpers\ArrayHelper; ?> <p>Seleccione Número de toma y Cantón del que desea revisar los Porcentajes de los Indicadores </p> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'num_tom')->dropDownList(array('prompt' => '--select--', '1' => 1, '2' => 2, '3' => 3, '4' => 4, '5' => 5)); ?> <?php echo $form->field($model, 'canton')->dropDownList(ArrayHelper::map(Canton::find()->all(), 'id_cant', 'nom_cant')); ?> <div class="form-group"> <?php echo Html::submitButton('Buscar', ['class' => 'btn btn-primary']); ?> </div> <?php ActiveForm::end(); ?>