Yii Framework Forum: Problem with UrlMenager and Search form - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Problem with UrlMenager and Search form Rate Topic: -----

#1 User is offline   micz 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 31
  • Joined: 05-June 09

Posted 08 July 2010 - 08:35 AM

I have problem with url manager and serach form. I have this form on my main layout:
<div class=" searchBar">
                    <?php echo CHtml::beginForm(array('/item/search'), 'get'); ?>
                    <?php echo CHtml::textField('string', $_GET['string'], array('size'=>60));?>
                    <?php echo CHtml::submitButton('szukaj',array('name'=>'form'));?>
                    <?php echo CHtml::endForm();?>
                </div>

And this rule in UrlManager:
'<form>-<string>'=>array('item/search', 'urlSuffix'=>'.html', 'caseSensitive'=>false),


When I use search form i url like this

mydomain.com/item/search?string=search+test&form=szukaj

when I enter url like this

mydomain.com/szukaj-searh+test.html

It works just fine, but I can't make it to generate this kind of url :(.
0

#2 User is offline   Mike 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 3,016
  • Joined: 06-October 08
  • Location:Upper Palatinate

Posted 08 July 2010 - 08:57 AM

The former URL is created by the browser when you use GET to submit a form. If you don't want that, you could either use POST for your form or attach some javascript to the submit event of the form, that creates the URL in the desired format and redirects the browser to that location.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users