A
A
Andrew2015-02-19 20:38:48
Yii
Andrew, 2015-02-19 20:38:48

How not to produce parameters in the url after repeated GET requests through a form in Yii?

Hello! Help me to understand.
There is a site on yii with a form of filters. The form sends a get request to filter the selection results. Each time the form is submitted, the list of parameters in the browser url increases.
For example, when you select the parameters for the first time and click the "Show" button, the url becomes like this:

http://name_domain.ru/list/page1.html?CategoryFilterForm[proportions]=
&CategoryFilterForm[seria]=&CategoryFilterForm[seria][]=Кошки
&CategoryFilterForm[availability]=&yt1=Показать

When changing the filter (adding/removing parameters), the list in the parameters url is increased by 1 set of filter parameters.
For example, when you select the parameters for the second time and click the "Show" button again, the url is:
http://name_domain.ru/list/page1.html?CategoryFilterForm[proportions]=
&CategoryFilterForm[seria]=&CategoryFilterForm[seria][]=Кошки
&CategoryFilterForm[availability]=&yt1=Показать
&CategoryFilterForm[proportions]=&CategoryFilterForm[seria]=
&CategoryFilterForm[seria][]=Кошки&CategoryFilterForm[seria][]=Собаки
&CategoryFilterForm[seria][]=Лошади&CategoryFilterForm[availability]=&
yt1=Показать

Moreover, the filter works without problems.
The form in the view is formed like this:
$CategoryFilter = new CategoryFilterForm;
  
$ComformCategoryFilter = $this->beginWidget('CActiveForm', array(
                        'id' => 'categoryfilter-form',
                        'method' => 'get',
                        'enableClientValidation' => true,
                        'clientOptions' => array(
                          'validateOnSubmit' => true,
                        ),
                      ));

How to clear url of obsolete query parameters or force the form not to add, but to update the parameters?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dmeroff, 2015-02-19
@sorgo

You must manually specify an action for the form. Otherwise, the form is sent to a url that contains the parameters of previous requests.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question