S
S
Sergey Beloventsev2016-05-30 14:21:02
Yii
Sergey Beloventsev, 2016-05-30 14:21:02

How to generate beautiful addresses when using forms?

here is the form

<?php $form=ActiveForm::begin(['action'=>Yii::$app->urlManager->createUrl(['/serial/category/search']),'method'=>'get']); ?>
 <?= Html::textInput('query','',['placeholder'=>'Поиск']) ?>
        <div class="form-group">
            <?= Html::submitButton('<i class="fa fa-search"></i>') ?>
        </div>
        <?php $form=ActiveForm::end(); ?>

this is how I try to catch it in the rules urlManager.
'/serial/category/search/<query>' => '/serial/category/search',
            '/serial/category/search/<query:\w*>' => '/serial/category/search',
            '<module:serial>/<controller:category>/<action:searh>/<query>' => '<module>/<controller>/<action>',
            '<module:serial>/<controller:category>/<action:searh>/<query:\w*>' => '<module>/<controller>/<action>',
            '<module:\w+>/<controller:\w+>/<action:(\w|-)+>/<query>' => '<module>/<controller>/<action>',
            '<module:\w+>/<controller:\w+>/<action:(\w|-)+>/<query:\w*>' => '<module>/<controller>/<action>',
    '<module:\w+>/<controller:\w+>/<action:(\w|-)+>' => '<module>/<controller>/<action>',

only the rule triggers the rule, respectively, such a line comes
http://site.com/serial/category/search?query=Запрос

All these body movements in order to receive such a request plan http://site.com/serial/category/search/Запрос, where am I stupid, do not tell me?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DuD, 2016-06-10
@DuD

It is better to POST from the form and then redirect to the correct URL.
Or make a form in JS so that when you click the button, you redirect to the correct URL

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question