Joomla 2.5 form redirection error

2019-07-25 23:42发布

问题:

Here is my form

<form name="form1" action="<?php echo JRoute::_('index.php?option=com_mycomponent&task=search')?>" method="get">            
<input id="search_key" name="searchword" type="text" class="inputbox" placeholder="Enter Keyword/Part Number..." autocomplete="off">
<input type="submit" class="inputbutton" value="Search">
</form>  

After entering any keyword say 'test', it redirects to index.php?searchword=test

But i need to redirect it to index.php?option=com_mycomponent&task=search&searchword=test

it is not working either in sef enabled/disabled

when i type index.php?option=com_mycomponent&task=search&searchword=test in url, i go to the desired page.

Please tell me where am i wrong

回答1:

Can you try changing:

<form name="form1" action="<?php echo JRoute::_('index.php')?>" method="get">

to

<form name="form1" action="<?php echo JRoute::_('index.php')?>" method="get">
<input type="hidden" name="option" value="com_mycomponent">
<input type="hidden" name="task" value="search">


标签: php forms joomla