mardi 15 décembre 2015

How to store radio button value in database using laravel

I am creating a form, in which I have used radio buttons. For storing radio button's value in database I am using boolean as a datatype, but after submitting form value stored in database is always 0.

here is my code:

blade:

<div class="form-group">
    {!! Form::label('is_kids_only','Kids Only:') !!}
    {!! Form::radio('kidsonly', 'true', null),'&nbsp', 'Yes' !!}
    {!! Form::radio('kidsonly', 'false', null),'&nbsp','No' !!}
</div>

Controller:

public function store(EventRequest $request) {
     Event::create($request->all());
     return redirect('event'); 
}

What can I do, to store the value in database, and when I edit that form, it should auto select radio button according to database value.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire