亲爱的,
我不确定原因,但价值" related_home-> Home_name"我单击提交后,在视图中选择以某种方式丢失,因为数据转储返回null。有什么想法吗?
路线:
Route::post('/analysis/output', array(
'as' => 'analysis-output',
'uses' => 'AnalysisController@postAnalysis'
));
查看:
@extends('layout.main')
@section('content')
<form action="{{URL::route('analysis-output')}}" method="post">
<select>
@foreach($relevant_homes as $relevant_home)
<option value="{{$relevant_home->Home_name}}">{{$relevant_home->Home_name}}</option>
@endforeach
</select>
<input type='submit' value='Analyse'>
{{ Form::token() }}
</form>
@stop
控制器:
<?php
class AnalysisController extends BaseController {
public function postAnalysis(){
echo $relevant_home = Input::get('relevant_homes');
dd($relevant_home);
}
}
?>
答案 0 :(得分:0)
你没有给你的select
一个名字。请在您的视图中尝试此操作:
@extends('layout.main')
@section('content')
<form action="{{URL::route('analysis')}}" method="post">
<select name="relevant_homes">
@foreach($relevant_homes as $relevant_home)
<option value="{{$relevant_home->Home_name}}">{{$relevant_home->Home_name}}</option>
@endforeach
</select>
<input type='submit' value='Analyse'>
{{ Form::token() }}
</form>
@stop
答案 1 :(得分:0)
尝试
{{ Form::open(array('route' => 'analysis-output')) }}
<select name='relevant_homes' id='relevant_homes'>
@foreach($relevant_homes as $relevant_home)
<option value="{{$relevant_home->Home_name}}">{{$relevant_home->Home_name}}</option>
@endforeach
</select>
{{ Form::submit('Analyse') }}
{{ Form::close() }}
如果那不起作用,选项字段实际上有什么内容吗?