【发布时间】:2017-02-01 06:00:48
【问题描述】:
我有两 (2) 页。一个是创建页面,另一个是确认页面。创建页面有一个表单和一个“继续确认”按钮,该按钮将重定向到确认页面。确认页面应显示来自创建页面的所有输入,然后用户在检查完所有输入值后即可提交。
控制器:
public function create()
{
return ('pages.create');
}
public function confirmCreate()
{
$value = Input::all();
Session::flash('value', $value);
return view('pages.confirm-create')->with('value', $value);
}
路线:
Route::get('create', 'MyController@create')->name('create');
Route::post('confirm-create', 'MyController@confirmCreate')->name('confirm-create');
Route::put('store', 'MyController@store')->name('store');
创建页面视图:
{{ Form::open(array('url' => 'confirm-create',
'method' => 'POST',
'class' => 'form-horizontal')) }}
<div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}">
<label class="col-md-4 control-label required">Name</label>
<div class="col-md-6">
<input id="name" placeholder="Name" type="text" class="form-control" name="name" value="{{ old('name) }}" required autofocus>
@if ($errors->has('name'))
<span class="help-block">
<strong>{{ $errors->first('name') }}</strong>
</span>
@endif
</div>
</div>
<div class="form-group{{ $errors->has('contactNumber') ? ' has-error' : '' }}">
<label class="col-md-4 control-label required">Contact Number</label>
<div class="col-md-6">
<input id="contactNumber" placeholder="Contact Number" type="text" class="form-control" name="contactNumber" value="{{ old('contactNumber) }}" required autofocus>
@if ($errors->has('contactNumber'))
<span class="help-block">
<strong>{{ $errors->first('contactNumber') }}</strong>
</span>
@endif
</div>
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-6">
<button type="submit" class="btn btn-primary">
Proceed to Confirm
</button>
</div>
</div>
{{ Form::close() }}
确认页面查看:
{{ Form::open(array('url' => 'pages',
'method' => 'POST',
'class' => 'form-horizontal')) }}
<div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}">
<label class="col-md-4 control-label required">Name</label>
<div class="col-md-6">
<label class="control-label">{{ old('name') }}</label>
@if ($errors->has('name'))
<span class="help-block">
<strong>{{ $errors->first('name') }}</strong>
</span>
@endif
</div>
</div>
<div class="form-group{{ $errors->has('contactNumber') ? ' has-error' : '' }}">
<label class="col-md-4 control-label required">Contact Number</label>
<div class="col-md-6">
<label class="control-label">{{ old('contactNumber') }}</label>
@if ($errors->has('contactNumber'))
<span class="help-block">
<strong>{{ $errors->first('contactNumber') }}</strong>
</span>
@endif
</div>
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-6">
<button type="submit" class="btn btn-primary">
Submit
</button>
</div>
</div>
{{ Form::close() }}
我似乎无法从我的创建页面(单击“继续确认”按钮后)将数据显示到我的确认页面。我的控制器、路由和视图(创建和确认页面)应该是什么样子?发送帮助。谢谢!
【问题讨论】:
标签: php forms laravel laravel-5