0

I have a controller called CharactersController.php in my controllers directory. Here are the two functions:

    public function search()
{
    return View::make('search.search');
}

public function post_search()
{
    $name = Input::get('character');
    $searchResult = Player::where('name', 'LIKE', '%'.$name.'%')->paginate(5);
    return View::make('search.post_search')
            ->with('name', $name)
            ->with('searchResult', $searchResult);
}

In the first function (function search()) I return a view. Here's the code of the view(just the form):

        <form id="custom-search-form" class="form-search form-horizontal pull-right" action="{{ URL::action('CharactersController@post_search') }}" method="get">
        <div class="input-append spancustom">
            <input type="text" class="search-query" name="character" placeholder="Character/guild name">
            <button type="submit" class="btn"><i class="icon-search"></i></button>
        </div>
    </form>

When I try to run the form (to search) I get an Unknown action [CharactersController@post_search]. error. I had this error before, I tried switching controllers, tried doing everything. But it didn't work. So I gave up.

Anyone who can solve it?

4

3 回答 3

0

是那个控制器RESTful?

您是否Route::controller()在 routes.php 中创建了一个?

如果不是,您可以尝试在方法标题中RESTFul删除吗?post_

于 2013-08-19T03:27:39.280 回答
0

每个PSR-1函数名称都需要采用驼峰命名法。将 post_search 更改为 postSearch

于 2013-08-18T17:19:51.987 回答
0

你真的为控制器的方法定义了一个路由吗?你需要这样做,否则当你调用时会抛出讨厌的异常URL::action()

于 2013-08-18T15:57:58.590 回答