フォームから別のページに値を渡して、laravelアプリケーションに助けが必要です。私はエリアオブジェクトに関するデータを持つテーブルを持っており、2つ(またはそれ以上)のエリアオブジェクトを選択して、それらを新しいページで見ることができるようにしたいと考えています。私index.blade.phpでフォームデータをLaravelの別のページに渡す方法
私が空洞の形を持っている:
<form method = "POST" action="/areas/comparison" id="preferencesForm" class="form-group">
!{csrf_field()}!
<table id='areas_table' class="table table-striped">
<thead class="thead-default">
<tr>
<th>Select</th>
<th>Area</th>
<th>Overall Score</th>
<th>Housing Affordability Ratio</th>
<th>Mean House Price</th>
<th>Crime Level</th>
<th>Green Space</th>
<th>Good GCSE's</th>
<th>Number of Pubs & Restaraunts:</th>
<th>Superfast Broadband</th>
</tr>
</thead>
<tbody>
@foreach ($areas as $area)
<tr>
<td scrope="row"><input type="checkbox" name="area[]" value="!{$area->id}!"></td>
<th><a href="/areas/!{$area->id}!">!{$area->name}!</a></th>
<td>!{Helpers::calculateOverallScore($area)}!</td>
<td>!{$area->housing_affordability_ratio}!</td>
<td>£!{$area->mean_house_price_2015}!</td>
<td>!{$area->crime}!</td>
<td>!{$area->greenspace*100}!%</td>
<td>!{$area->five_good_gcses*100}!%</td>
<td>!{$area->restaurants}!/km<sup>2</sup></td>
<td>!{$area->superfast_broadband*100}!%</td>
</tr>
@endforeach
@endif
</tbody>
</table>
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<input type="submit" id="compare_button" class="btn btn-primary" value="Compare"/>
</form>
そして、私はそれから(またはそれ以上をshow_comparison.blade.phpと2上のデータを表示できるように行きたいです私が選んだ地域です。 routes.phpの中
私が持っている:AreasControllerで
Route::post('/areas/comparison', '[email protected]_comparison');
そして:私は、[送信]をクリックしますと、それは私がshow_comparison.blade.phpする取ってみると
public function show_comparison(Area $area)
{
$formData = Request::all(); //Get the form data with the facade
return view('areas.show_comparison', compact('formData'));
}
をしかし、それはエラーを返しますメッセージ "非オブジェクトのプロパティを取得しようとしています"。ここ
はshow_comparison.blade.phpある: @extends( 'レイアウト')
@section('content')
<div class="container">
<a href="/areas" class="btn btn-primary">Back</a>
<h1>Comparison</h1>
<p>Hello, this is the comparison page. !{$formData}!</p>
</div>
@stop
理想的には、私は{area1->名}の形式でデータを印刷できるようにしたいと思います!と!{area2-> name}!私の選択によると。
誰かが自分のフォームを選択したデータを別のページに渡す必要があることを誰かが見せてくれれば驚くはずです。 (読んでいただきありがとうございます)
あなたは私たちにあなたの 'show_comparison.blade.php'コードを表示できますか? –
私はビューを追加しました。 –