D
D
driverx182017-08-16 11:46:58
Yii
driverx18, 2017-08-16 11:46:58

How to set up selection filters properly in Yii2?

I have filters on my site, we take the most banal as an example, for example: show the most recent posts, and show the latest posts. I need to click on the radio button, for example, of recent posts, to refresh the page (and even cooler so that it does not refresh, but the posts appear the most recent (perhaps PJAX?)). How to do so? Do you need to make a name for the radio button in HTML, and using JS to make it so that if the radio button is clicked, the form is sent automatically, let's say the POST parameter? And there it gets to the server, in some action and in the action we look, if the post parameter $_POST['recent_posts'] came, then select the most recent posts from the model, and if $_POST['old_posts'] then the oldest posts?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
davidnum95, 2017-08-16
@davidnum95

In general terms, it is.

M
Maxim Timofeev, 2017-08-16
@webinar

make a form, wrap the inputs you need in it in pjax, send the form when you click. We also wrap the results in pjax and specify which container to update in the pjax config.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question