/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Position::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(['position_id' => $this->position_id]); $query->andFilterWhere(['like', 'position_name', $this->position_name]); return $dataProvider; }
<?php $form = ActiveForm::begin(); ?> <div class="column1"> <?php echo $form->field($model, 'id_number')->textInput(['maxlength' => true, 'style' => 'width: 300px']); ?> <?php echo $form->field($model, 'lastname')->textInput(['maxlength' => true, 'style' => 'width: 300px']); ?> <?php $position = Position::find()->all(); $listData = ArrayHelper::map($position, 'position_id', 'position_name'); echo $form->field($model, 'position_id')->dropDownList($listData, ['prompt' => 'Select Position', 'style' => 'width: 300px']); ?> </div> <div class="column2"> <?php echo $form->field($model, 'user_id')->textInput(['style' => 'width: 300px']); ?> <?php echo $form->field($model, 'firstname')->textInput(['maxlength' => true, 'style' => 'width: 300px']); ?> <?php echo $form->field($model, 'employee_status')->dropDownList(['Active' => 'Active', 'Inactive' => 'Inactive'], ['prompt' => 'Select status', 'style' => 'width: 300px']); ?>
$form = ActiveForm::begin(); ?> <!--<?php echo $form->field($model, 'position_id')->dropDownList(ArrayHelper::map(\common\models\Position::find()->all(), 'id', 'positionName'), ['prompt' => 'Position']); ?> --> <!--<?php echo $form->field($model, 'section_id')->dropDownList(ArrayHelper::map(\common\models\Section::find()->all(), 'id', 'sectionName'), ['prompt' => 'Section']); ?> --> <?php //$form->field($model, 'position_id') echo $form->field($model, 'position_id')->widget(Select2::classname(), ['data' => ArrayHelper::map(\common\models\Position::find()->all(), 'id', 'positionName'), 'options' => ['placeholder' => 'Select a position'], 'pluginOptions' => ['allowClear' => true]]); ?> <?php //$form->field($model, 'section_id') echo $form->field($model, 'section_id')->widget(Select2::classname(), ['data' => ArrayHelper::map(\common\models\Section::find()->all(), 'id', 'sectionName'), 'options' => ['placeholder' => 'Select a section'], 'pluginOptions' => ['allowClear' => true]]); ?> <?php echo $form->field($model, 'userFName')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'userMName')->textInput(['maxlength' => true]); ?>