File tree Expand file tree Collapse file tree 3 files changed +25
-11
lines changed
Expand file tree Collapse file tree 3 files changed +25
-11
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,21 @@ public function getFieldActualName(View $view)
4444 return $ name ;
4545 }
4646
47+ public function getFieldOptions (View $ view )
48+ {
49+ if (!$ view ->offsetExists ('options ' )) return null ;
50+
51+ $ options = $ view ->offsetGet ('options ' );
52+
53+ if ($ options instanceof \Illuminate \Support \Collection) {
54+ $ options = $ options ->toArray ();
55+ }
56+
57+ return array_filter ($ options , function ($ value ) {
58+ return !empty ($ value );
59+ });
60+ }
61+
4762 public function getExtraAttributes (View $ view )
4863 {
4964
Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ public function compose(View $view)
3434 $ view ->offsetSet ('value ' , $ this ->attributeManager ->getFieldValue ($ view ));
3535 $ view ->offsetSet ('type ' , $ this ->attributeManager ->getFieldType ($ view ));
3636 $ view ->offsetSet ('actualName ' , $ this ->attributeManager ->getFieldActualName ($ view ));
37+ $ view ->offsetSet ('options ' , $ this ->attributeManager ->getFieldOptions ($ view ));
3738 $ view ->offsetSet ('onlyTemplate ' , in_array ($ fieldType , ['checkbox ' ]));
3839 $ view ->offsetSet ('model ' , app (FormModelStack::class)->current ());
3940 }
Original file line number Diff line number Diff line change 33 <option ></option >@endif
44 @foreach ($options as $optValue => $optText )
55 @if (is_array ($optText ) )
6- @foreach ($optText as $optionValues )
7- <optgroup label =" {{ $optValue } }" >
8- @foreach ($optionValues as $optGroupOptValue => $optGroupOptText )
9- @if (is_array ($value ) ? in_array ($optGroupOptValue , $value ) : $optGroupOptValue === $value )
10- <option value =" {{ $optGroupOptValue } }" selected >{{ $optGroupOptText } } </option >
11- @else
12- <option value =" {{ $optGroupOptValue } }" >{{ $optGroupOptText } } </option >
13- @endif
14- @endforeach
15- </optgroup >
16- @endforeach
6+ <optgroup label =" {{ $optValue } }" >
7+ @foreach ($optText as $optGroupOptValue => $optGroupOptText )
8+ @if (is_array ($value ) ? in_array ($optGroupOptValue , $value ) : $optGroupOptValue === $value )
9+ <option value =" {{ $optGroupOptValue } }" selected >{{ $optGroupOptText } } </option >
10+ @else
11+ <option value =" {{ $optGroupOptValue } }" >{{ $optGroupOptText } } </option >
12+ @endif
13+ @endforeach
14+ </optgroup >
1715 @else
1816 @if (is_array ($value ) ? in_array ($optValue , $value ) : $optValue === $value )
1917 <option value =" {{ $optValue } }" selected >{{ $optText } } </option >
You can’t perform that action at this time.
0 commit comments