I am currently working on a drop down within my form and it is returning the index value eg 0,1,2 when the box is selected. I need it to return the literal text within the box eg 'Server One','Server Two' . I am working with the laravel collective forms. attached is the code snippet for the form. Any help would be much appreciated! The variable $statuses is the list of all the servers within the database.
@extends('layouts.app')
@section('content')
<h1></h1>
<h1>Edit Incident</h1>
{!! Form::open(['action' => ['IncidentsController@update', $incident->id], 'method' =>'POST']) !!}
<div class="form-group">
{{Form::label('title','Title')}}
{{Form::text('title',$incident->title,['class' => 'form-control', 'placeholder' => 'Title'])}}
{{Form::label('body','Body')}}
{{Form::textarea('body',$incident->body,['id' => 'article-ckeditor','class' => 'form-control', 'placeholder' => 'Body text'])}}
{{Form::label('status','Server Status:')}}
<br>
{{Form::label('status','Resolved:')}}
{{Form::radio('status', 'Resolved' , false) }}
<br>
{{Form::label('status','Unresolved:')}}
{{Form::radio('status', 'Unresolved' , true) }}
<br>
{{ Form::label('server', 'Server:') }}
<br/>
{{Form::select('server', $statuses),['name' => "server",'class' => 'form-control']}}
</div>
{{Form::hidden('_method', 'PUT')}}
{{Form::submit('Submit', ['class' => 'btn btn-primary'])}}
{!! Form::close() !!}
dd($server)
@endsection
createIncident:
public function createIncident(){
$statuses = Status::pluck('server');
dd($statuses);
return view('createIncident', ['statuses' => $statuses]);
}
ended up changing the way I displayed and stored the form itself and used select tags to fix it.
<select name="server">
@foreach($statuses as $key => $value)
<option>{{$value}}</option>
@endforeach
</select>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.