Note that there are some explanatory texts on larger screens.

plurals
  1. POCustom route and form get parameters
    primarykey
    data
    text
    <p>I have the following route set up</p> <pre><code>routes.jobSearch.type = "Zend_Controller_Router_Route" routes.jobSearch.route = "job/:sector/search/:sectorID/:subSectorID/:regionID/:jobTypeID/:ignore/:keywords/:page" routes.jobSearch.defaults.module = "site" routes.jobSearch.defaults.controller = "job" routes.jobSearch.defaults.action = "search" routes.jobSearch.defaults.keywords = "" routes.jobSearch.regs.sector = "\w+" </code></pre> <p>And aslo I have this Zend_Form which provides search interface. But when I submit the form, the url becomes</p> <pre><code>http://localhost/job/all/search?search_sector=1&amp;search_sub_sector=0&amp;world_area=0&amp;job_type=0&amp;search_submit=Submit+Query&amp;keywords= </code></pre> <p>and because of this my custom route is not matched. So is there a way to do this?</p> <p>[EDIT] Here is the new route which didn't work either</p> <pre><code>routes.jobSearch.type = "Zend_Controller_Router_Route" routes.jobSearch.route = "job/:sector/search/:search_sector/:search_sub_sector/:world_area/:job_type/:search_submit/:keywords" routes.jobSearch.defaults.module = "site" routes.jobSearch.defaults.controller = "job" routes.jobSearch.defaults.action = "search" </code></pre> <p>[EDIT ref:@Jani] This is my route now</p> <pre><code>routes.jobSearch.route = "job/:sector/search/:subSectorID/:regionID/:jobTypeID/:search_submit/:keywords/:page" routes.jobSearch.defaults.module = "site" routes.jobSearch.defaults.controller = "job" routes.jobSearch.defaults.action = "search" routes.jobSearch.defaults.sector = "all" routes.jobSearch.defaults.subSectorID = "0" routes.jobSearch.defaults.regionID = "0" routes.jobSearch.defaults.jobTypeID = "0" routes.jobSearch.defaults.search_submit = "Submit+Query" routes.jobSearch.defaults.keywords = "" routes.jobSearch.defaults.page = "1" </code></pre> <p>and it matches correctly. At least I get the search result page. But all passes parameters are set to their defaults. So if I hit this url <a href="http://localhost/job/pharmaceutical/search?subSectorID=1&amp;regionID=1&amp;jobTypeID=1&amp;search_submit=Submit%20Query&amp;keywords=drugs" rel="nofollow">http://localhost/job/pharmaceutical/search?subSectorID=1&amp;regionID=1&amp;jobTypeID=1&amp;search_submit=Submit%20Query&amp;keywords=drugs</a> and if I do <code>var_dump($this-&gt;getRequest()-&gt;getParams())</code> I expect to see</p> <pre><code>array 'sector' =&gt; string 'pharmaceutical' (length=14) 'module' =&gt; string 'site' (length=4) 'controller' =&gt; string 'job' (length=3) 'action' =&gt; string 'search' (length=6) 'subSectorID' =&gt; string '1' (length=0) 'regionID' =&gt; string '1' (length=1) 'jobTypeID' =&gt; string '1' (length=1) 'search_submit' =&gt; string 'Submit+Query' (length=12) 'keywords' =&gt; string 'drugs' (length=0) 'page' =&gt; string '1' (length=1) </code></pre> <p>but what I get is</p> <pre><code>array 'sector' =&gt; string 'pharmaceutical' (length=14) 'module' =&gt; string 'site' (length=4) 'controller' =&gt; string 'job' (length=3) 'action' =&gt; string 'search' (length=6) 'subSectorID' =&gt; string '0' (length=0) 'regionID' =&gt; string '0' (length=1) 'jobTypeID' =&gt; string '0' (length=1) 'search_submit' =&gt; string 'Submit+Query' (length=12) 'keywords' =&gt; string '' (length=0) 'page' =&gt; string '1' (length=1) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload