public function actionCountryShow() { $query = Country::find(); $pagination = new Pagination(['defaultPageSize' => 5, 'totalCount' => $query->count()]); $countries = $query->orderBy('name')->offset($pagination->offset)->limit($pagination->limit)->all(); return $this->render('country-by-page', ['countries' => $countries, 'pagination' => $pagination]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Country::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(['population' => $this->population]); $query->andFilterWhere(['like', 'code', $this->code])->andFilterWhere(['like', 'name', $this->name]); return $dataProvider; }
?> <?php echo $form->field($commentForm, 'comment_writer')->textInput(); ?> <?php echo $form->field($commentForm, 'comment_w_email'); ?> <?php echo $form->field($commentForm, 'comment_w_phone')->textInput(); ?> <?php echo $form->field($commentForm, 'country')->DropDownList(ArrayHelper::map(array_merge(Country::find()->all()), 'country_id', 'country_name'), ['prompt' => 'Select your country']); ?> <?php echo $form->field($commentForm, 'comment_w_gender')->inline()->radioList(['M' => 'Male', 'F' => 'Female'], ['options' => ['unselect' => null]]); ?> <?php echo $form->field($commentForm, 'comment_subject')->textInput(); ?> <?php echo $form->field($commentForm, 'comment_message')->textarea(); ?> <div class="form-group">
public static function getCountryList() { $droptions = Country::find()->asArray()->all(); return Arrayhelper::map($droptions, 'id', 'name'); }