I have a form created for editing a Trip. One field is 'Public' which is a boolean. When public is checked as true, I can't get it to show and update on the edit form.
addTrip.blade.php
<div class="form-group">
{!! Form::label('public', 'Make Trip Itinerary Public') !!}
{!! Form::checkbox('public', 'value'); !!}
</div>
editTrip.blade.php
<div class="form-group"> Make Public
<input type="checkbox" name="public" class="switch-input" value="" />
</div>
TripController
public function update(Request $request, $id)
{
$this->validate($request, [
'name' => 'required',
'email' => 'required',
'destination' => 'required',
'startdate' => 'required',
'enddate' => 'required',
'user_id' => 'required',
]);
//Update Trip
$trip = Trip::find($id);
$trip->name = $request->input('name');
$trip->email = $request->input('email');
$trip->destination = $request->input('destination');
$trip->startdate = $request->input('startdate');
$trip->enddate = $request->input('enddate');
$trip->public = $request->has('public');
$trip->save();
return redirect('trips')->with('sucess', 'Trip Updated');
}
Aucun commentaire:
Enregistrer un commentaire