Laravel 4: Input::get() is not working

后端 未结 3 906
故里飘歌
故里飘歌 2021-01-23 09:42

Something weird is happening in my production server using CentOS 7 and the problem is... in my local environment I have many applications developed with Laravel 4 and were inst

相关标签:
3条回答
  • 2021-01-23 09:45
    {{ Form::open(array('method' => 'GET', 'action' => 'CompanyController@search', 'class' => 'f-search')) }}
    

    Try changing 'action' => 'buscar'.

    0 讨论(0)
  • 2021-01-23 10:03

    I believe the issue lies on your .htaccess file on the server. The RewriteRule is not properly done. Find the similar line and fix as follows.

    RewriteRule ^(.*)$ /index.php?/$1 [QSA]
    

    [QSA] is the changed section

    0 讨论(0)
  • 2021-01-23 10:05

    I just did a test locally using the following settings:

    // routes.php
    Route::get("/test", "AppController@test");
    
    // AppController.php
    public function test() { 
      print_r(Input::get("test"));
      return View::make("test");
    }
    
    // test.blade.php
    <form method="GET" action="{{ URL::to("test")}} ">
      <input type="text" name="s" class="form-control">
      <input type="submit">
    </form>
    

    After pressing Submit, the url changes to localhost/sotests/test?s=test and the page returns with "test" printed right above the form.

    Some changes, I used URL::to("test") as my action. I don't know if that will fix your issue, but it worked like a charm for me. Other than that, I also didn't use Laravel's Form class, but I don't think that would make a difference.

    Let me know if this works for you!

    0 讨论(0)
提交回复
热议问题