【发布时间】:2019-03-12 01:06:12
【问题描述】:
问候。
我正在尝试从自身调用索引视图,以查找人员并在左侧显示结果。
但是当我调用视图并发送数据时它总是为空,请你给我一个线索。我什至调用了 store 函数,请求总是为空。
应该是模态窗口来获取请求对象吧?如果我想在执行过程中显示窗口,我应该怎么做?
我的路线
Route::get('registroaccesos/destinationSearchGet/', 'RegistroAccesosController@destinationSearchGet')->name('registroaccesos.destinationSearchGet');
Route::post('registroaccesos/destinationSearchPost/', 'RegistroAccesosController@destinationSearchPost')->name('registroaccesos.destinationSearchPost');
控制器
public function destinationSearchGet(){
$headData = array('pageTitle' => 'Admin Home - View all destinations');
return view('registroaccesos.index', $headData);
}
public function destinationSearchPost(Request $request){
$headData = array('pageTitle' => 'Admin Home - Search results');
$formData = $request->input('strPatron');
dd($formData);
// $data = ParentRegionList::destinationSearch($formData);
return view('registroaccesos.index', $headData);//->with(compact('data'))
}
景色
视图的部分代码
<h6 class="sidebar-heading d-flex justify-content-between align-items-center px-3 mt-4 mb-1 text-muted">
<span>Acciones</span>
<a class="d-flex align-items-center text-muted" href="#">
<span data-feather="plus-circle"></span>
</a>
</h6>
<div class="form-group">
<label for="strSearch" class="col-form-label">Patrón de búsqueda</label>
<select name="strSearch" class="form-control">
<option value="1" selected> Código del usuario</option>
<option value="2" > Nombre del usuario</option>
</select>
</div>
<div class="form-group">
<input placeholder="Patrón de búsqueda"
id="strPatron"
required
name="strPatron"
spellcheck="false"
class="form-control"
value="Valor"
/>
</div>
<button class="btn btn-sm btn-outline-secondary"
onclick="
event.preventDefault();
document.getElementById('search-form').submit();
"
>Buscar</button>
<form id="search-form" action="{{ route('registroaccesos.store','el resultado' ) }}" method="POST" style="display: none;">
<!-- <input type="hidden" name="_method" value="delete">-->
{{ csrf_field() }}
</form>
结果
【问题讨论】:
-
你能显示你已经命名了哪个请求吗?
-
您需要将
<input>标签放在<form></form中。现在您正在提交空表单 -
那么应该是模态的吗?
-
正如@RaheelKhan 所说,用
form包装每个input -
检查this。
标签: php laravel laravel-5.5