M
M
Maxim Lagoysky2018-05-19 11:19:31
Yii
Maxim Lagoysky, 2018-05-19 11:19:31

How to convert url when submitting a form?

There is a link like site.ru/site/search?make=1&model=2 , with the help of my routing rules I was able to convert this link into this type site.ru/search/audi/a100 like everything is fine.
After I was happy I created a search form and then a problem appeared, when sending the get form with a request to the site.ru/site/search + get parameters selected by users in the make and model fields, I get the site.ru/site/search?make=1&model link =2 .
If I just paste the link like this, then I get what I need:

<a href="<?=Url::to(['/site/search', 'make' => 1, 'model' => 2])?>">

And if the request is sent with the same get parameters through the form, then the url is not converted
<form action="<?=Url::to(['/site/search'])?>" method="GET">
    <select name="make">
        <option value=1>Audi</option>
    </select>
    <select name="model">
        <option value=2>A 100</option>
    </select>
</form>

The question is how to deal with these? What are the solutions?
I read about the decision that the link should be formed in js and when you click on the search button, follow the link made in js? but is there any other solution?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Arthur, 2018-05-19
@lagoy

ajax

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question