我想从视图中向控制器发送值,它即将到来" null",我期待输入搜索按钮,
观看页面代码:
{{ Form::open(['method'=>'POST','action'=>'searchingDoctors','class'=>'navbar-form navbar-left','role'=>'search']) }}
<div class="input-group custom-search-form">
<input type="text" class="form-control" name="search" placeholder="Search...">
</div>
<input type="submit" id="search" name="search" value="Serach" class="search" />
{{ Form::close() }}
route.php代码:
Route::post('searchingDoctors/{search}', array('as'=>'searchingDoctors','uses'=>'PublicSearchController@searchingDoctors'));
控制器文件代码:
public function searchingDoctors($search) {
dd($data = Input::get($search));
}
答案 0 :(得分:1)
您需要在控制器中执行以下操作
public function searchingDoctors() {
$data = Input::get("search");
}
从
更改路线Route::post('searchingDoctors/{search}', array('as'=>'searchingDoctors','uses'=>'PublicSearchController@searchingDoctors'));
到
Route::post('searchingDoctors, array('as'=>'searchingDoctors','uses'=>'PublicSearchController@searchingDoctors'));
修改强>
同时将视图更改为以下
{{ Form::open(['method'=>'POST','action'=>'searchingDoctors','class'=>'navbar-form navbar-left','role'=>'search']) }}
<div class="input-group custom-search-form">
<input type="text" class="form-control" name="search" placeholder="Search...">
</div>
<input type="submit" id="search" name="search-button" value="Serach" class="search" />
{{ Form::close() }}
答案 1 :(得分:0)
试试这个:
public function searchingDoctors() {
dd($data = Input::get('search'));
}
并确保您已导入
use Illuminate\Support\Facades\Input;