]> _ Git - cubist_cms-back.git/commitdiff
wip #5468
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 28 Oct 2022 15:11:53 +0000 (17:11 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 28 Oct 2022 15:11:53 +0000 (17:11 +0200)
src/resources/views/fields/select2_from_array.blade.php

index a04b1789716a5d7fd15e9a0ac4192da71074c771..da87ff6724d97bde05d17b421d4389ec14a94d7e 100644 (file)
@@ -48,11 +48,24 @@ if($ajax){
     @endif
 
     @if (count($field['options']))
-        @foreach ($field['options'] as $key => $value)
+        @foreach ($field['options'] as $key => $data)
+            @php
+                $attrs='';
+                if(is_array($data)){
+                    $value=$data['value'];
+                    unset($data['value']);
+                    foreach ($data as $k=>$v){
+                        $attrs.=' '.$k.'="'.$v.'"';
+                    }
+                }else{
+                    $value=$data;
+                }
+
+            @endphp
             @if(!$is_null && select2_from_array_selected($key,$o))
-                <option value="{{ $key }}" selected>{{ $value }}</option>
+                <option value="{{ $key }}" selected {!! $attrs !!}>{{ $value }}</option>
             @elseif(!$ajax)
-                <option value="{{ $key }}">{{ $value }}</option>
+                <option value="{{ $key }}" {!! $attrs !!}>{{ $value }}</option>
             @endif
         @endforeach
     @endif