{{--
@//php($selected_value = 'b')
@//php($options = [ 'a' => 'test a', 'b' => 'test b', 'c' => 'test c'])
{{ $label }}
@foreach($options as $value => $label)
{{ $label }}
@endforeach
@foreach($options as $value => $label)
@endforeach
--}}
@props([
'name' => NULL,
'label' => NULL,
'error' => false,
'options' => [],
'selected' => NULL
])
{{-- Convert option arrays with ['name'=>'', 'label'=>''] in them to ['key' => 'value'] --}}
@php
if(!empty($options)) {
$array = [];
if(
is_array(current($options))
&& array_key_exists('name', current($options))
&& array_key_exists('label', current($options))
) {
foreach ($options as $option) $array[$option['name']] = $option['label'];
$options = $array;
}
}
@endphp