dimanche 25 décembre 2016

Laravel multiple checkboxes value

So, I'm having a lot of dynamically created checkbox groups in Laravel 5.2, which looks like this:

@foreach(App\EventOptionValue::where("event_option_id", 
                 $option->event_option_id)->get() as $value)
  {!! Form::label($option->event_option_id, $value->label) !!}
  {!! Form::checkbox($option->event_option_id . '[]', 
                 $option->event_option_value_id) !!}
@endforeach

On submit, I'm getting the right values, but the array's keys are numbers, and I can't validate them. Example of the post data:

"5452b688-4db2-32bf-94cd-4ceba532799c" => array:2 [
    0 => "on"
    1 => "on"
 ]

My question is, how can I submit the data more efficiently, with event_option_value_id's as keys in the array?




Aucun commentaire:

Enregistrer un commentaire