GET form with PATH url

Hi guys,

I’m just don’t getting a way to solve this problem. Check this out.

I have a form with GET method and action :


'action'=>$this::createUrl('busca/buscaGenerica')

The form generate a URL like this:


/busca/buscaGenerica?search=teste&btn_search=Buscar

I want to convert that to this:


/veiculos/teste/Buscar

In the UrlManager i tried this rule, but isn’t working:


'veiculos/<search>/<btn_search>' => 'busca/buscaGenerica',

Ideas?

Regards

Nobody?

Maybe this:




'veiculos/<search:\w+>/<btn_search:\w+>' => 'busca/buscaGenerica',



Yeah, i tried this…but don’t works.

I see.

In order to use the urlManager rule, you will need something like this:




$this::createUrl('busca/buscaGenerica', array('search' => $search_word, 'btn_search' => $btn_name)



Of course, I don’t think you can get $search_word and $btn_name before you submit the form …

Well, sorry, I’m lost too. :(

Look…if i try access the page using manually writing the url path, works fine, like this:


/busca/buscaGenerica/search/dd/btn_search/Buscar

But, my problem is…in the form, the URL don’t rewrite do path format.

Look my htaccess file:


RewriteEngine on

# if a directory or a file exists, use it directly

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST-FILENAME} !-d


 

#otherwise forward it to index.php

RewriteRule ^.*$ index.php [NC,L]

Well, thank’s anyway.

Somebody Else?

well…


/veiculos?search=ddd&btn_search=Buscar

Still sucks. :confused:

The urlManger rules work on the server side, while your "search" word and "btn_search" name are determined on the client side in a form.

So, I guess you can’t get the right url by any urlManager rule. It will contain the query string part like ‘?search=xxxx&btn_search=yyyy’.

I would use a script to catch the submit event of the form and construct the right url on the fly and call it.

Well, are you sure about that?

I’ve seen some cases in the forum, people who managed to get the URLs working properly.

I’m just not getting. With me the solutions to this problem don’t work fine.

As far as I understand, yes.

Another solution may be using redirection.

Well, this problem still breaking my job. :confused:

Someone else could help me with this issue?

Hugs

  1. create an empty action in you controller something (e.g. search)

and you can do something like following in your search action


$this->redirect(array("searchresult/{$_GET['params1']}/$_GET['param2']"));

Seems that will work this way.

But this way would not be a bit wrong?

I myself have seen the same problem being solved just with rules in urlManager.