我有一个包含下拉菜单和提交按钮的表单。就像这样:
查看路径:webmasters/filters.blade.php
{{ Form::open() }}
{{ Form::select('filt', $Dropdown, 2) }}
{{ Form::Submit('Filter') }}
{{ Form::close() }}
{{ Form::close() }}
还有一个 Controller ,它使用从数据库查询的值填充下拉列表。就像这样:
Controller 名称:WebController.php
class WebController extends BaseController {
public function getFilters() {
$filters = Dropdown::getFilters();
return View::make('webmasters.filter',['Dropdown'=>$filters]);
}
这是我的路线:
Route::resource('topPage', 'WebController@getFilters');
getFilters 是一种模型方法,用于在数据库中查询下拉列表中的值。
我想在提交表单时调用 Controller 方法,以便该方法查询另一个数据库并根据下拉列表的选定值返回一个表(与下拉列表和提交按钮在同一页面上)。
我可能以错误的方式处理这个问题,所以如果有人给我提示,我将非常感激。我仍然不想在这方面使用 Ajax,因为我不知道如何解决它。
感谢您的帮助。
最佳答案
由于 Form::open()
创建的默认表单使用 POST,因此您只需在 Controller 中添加另一个方法即可完成设置
public function postFilters() {
$filt = Input::get('filt'); // getting the value of the select
}
关于php - 在 Laravel 表单提交上调用 Controller 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27224879/