1 month ago

What is the best way to add 2 values in a select drop option?

Posted 1 month ago by zabarah

I am looping through an api results that provides both a key and subkey that I need sent as a value for one option.

Currently I am adding both values and exploding them on the controller.

<select name="location" id="location" class="">
      @foreach($locations as $location)
            <option value="{{$location['type'] .'_' . $location['key'] }}">{{  $location['name]  }}</option>

and then in controller

$location = $research->locationFilter(explode('_', $request->location));

I would need to do this for 12 other inputs about the same way. Is there a more elegant and efficient method to do this?

Please sign in or create an account to participate in this conversation.