getherbert / herbert

The WordPress Plugin Framework:
http://getherbert.com/
632 stars 94 forks source link

Form redirects to the wrong URL even if the action URL is correct #109

Open giwrgos88 opened 8 years ago

giwrgos88 commented 8 years ago

Hello I did a panel that shows a list of clients on the module that I'm working on.

$panel->add([
    'type'   => 'panel',
    'as'     => 'mainPanel',
    'title'  => 'Clients',
    'slug'   => 'clients-index',
    'uses'   => __NAMESPACE__ . '\Http\Controllers\Admin\ClientController@index',
    'get'    => [
        'index' => __NAMESPACE__ . '\Http\Controllers\Admin\ClientController@index',
    ],
]);

The index function of the ClientController collects all the clients and shows them in a list the same way that wordpress is presenting the posts. Now I'm trying to add a search feature on the index so i did the following code in the list.twig

    <form  method="get" action="{{ panel_url('ClientsPlugin::mainPanel', {'action':'index'}) }}">
            <label class="screen-reader-text" for="post-search-input">Search Client:</label>
            <input type="text" id="search-client" name="search-client" value="">
            <input type="submit" name="submit" class="button button-primary" value="Search Client" />
    </form> 

before my table of my clients. Using the inspected element the action has the correct URL path but when I'm pressing the search button it redirects me to http://localhost/wp-admin/admin.php?search-client=zxcvcvzxc instead of http://localhost/wp-admin/admin.php?page=clients-index&search-client=zxcvcvzxc

Does anyone knows why?

jebog commented 8 years ago

I have the same problem and still looking for a solution

giwrgos88 commented 8 years ago

@marcamon2013 my temporary solution is to make post method instead of get

sajadghawami commented 8 years ago

@marcamon2013 @giwrgos88

having the same problem! using posts works, but changes the screen from wordpress to empty page.

So my workaround is a redirect to the GET-route -which works but isn't the most elegant way.

Any help on this issue is appreciated! I've been trying to debug this for quite some time now, but i cant really find the bug!

Any recommendations where to look?