【发布时间】:2015-03-05 17:46:12
【问题描述】:
您好,我在contact.blade.php 中发送了一个表格。我读到要使用 PUT 方法,您必须创建一个包含该方法的隐藏输入字段。
@if($do == 'edit')
{{ Form::model($contact, array('method' => 'PUT', 'route' => array('contact.update', $contact->id), 'id' => $do=='edit' ? $do.$contact->id : $do.$contact_type_id, 'form_id' => $do=='edit' ? $do.$contact->id : $do.$contact_type_id)) }}
{{ Form::hidden('_method', 'PUT') }}
@endif
....
{{ Form::submit('speichern', array('class' => 'btn btn-primary')) }}
</div>
{{ Form::close() }}
路线:
Route::put('/contact/{id}', array(
'uses' => 'ContactController@update',
'as' => 'contact.update'
));
控制器:
public function update($id)
{
dd(Input::all());
// //get user account data
// $user = User::find( Auth::id() );
// // validate input
// $v = Contact::dataValidation( Input::all() );
return Redirect::Route('user.edit', 1)->withSuccess("<em>Hans</em> wurde gespeichert.");
第一季度:
只要我打电话给dd(Input::all());,我就不会再被重定向,而是看到一个带有我的表单值的json。
第二季度:
我只是在调试它,所以我没有对其进行编程。所以我的第二个问题是:
据我了解,dd(Input::all()); 获取了我所有的表单数据。所以我不需要把它存储在某个地方吗?
【问题讨论】: