php - Laravel send value from dropdown list to controller -


i have following code in view page

 <form action="{{ action('answercontroller@handlecreate') }}" method="post" role="form">         <div class="form-group dropdown">             <label for="question">question</label>             <select  id="question" class="drop" name="question">                 @foreach($questions $question)                      <option value="{{$question->question}}">{{$question->question}}</option>                  @endforeach             </select>         </div> 

in controller have following code

$question = question::wherequestion(input::get('question'))->first();  $n = $question->id; 

they give me error @ $n=$question ->id telling trying property of non-object

instead of using question text value , query id afterwards why don't set id value beginning?

<select  id="question" class="drop" name="question">     @foreach($questions $question)         <option value="{{$question->id}}">{{$question->question}}</option>     @endforeach </select> 

and can input::get('question') , have id of selected question. if wanted full model:

$questionid = input::get('question'); $question = question::find($questionid); 

Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -