We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Search Form Params

Hi,

I am trying to submit a form with 'get' method and i want a clean url Form:

      {{ form("products/search", "method": "get") }}

<label >What:</label> {{ text_field("what") }} <label >Where:</label> {{ text_field("where") }} {{ submit_button("Search") }} {{ endForm() }}

Now, when user will click on Search button i want to submit for and url should be

/products/search/what_value/where_value

Thanks

Im afraid you have to use JavaScript to acomplish that.

Thanks.

uhh... i don't want to use js. i'm trying using phalcon...

Well technically you could do it without javascript, here are 2 options that come to mind:

1) Send form to the url, process the query params and then redirect to the clean url you desire;

2) Make a rewrite with htaccess;

  1. i tried and it's working. But in that case, it's increasing server load because i did

    $keyword = $this->request->getQuery('what');
    $location = $this->request->getQuery('where');
    return $this->response->redirect("search/".$keyword.'/'.$location);