Skip to content

Commit

Permalink
Merge pull request bagisto#9213 from suraj-webkul/configuration-multi…
Browse files Browse the repository at this point in the history
…select

fix configuration multiselect was not working properly.
  • Loading branch information
jitendra-webkul authored Dec 28, 2023
2 parents aa858bb + 3a253b5 commit 530fc29
Showing 1 changed file with 33 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,8 @@ class="text-gray-600 dark:text-gray-300"
@endforeach
@else
@foreach ($field['options'] as $option)
@php
$value = ! isset($option['value']) ? null : ( $value = ! $option['value'] ? 0 : $option['value'] );
@endphp

<option
value="{{ $value }}"
value="{{ $option['value'] ?? 0 }}"
{{ $value == $selectedOption ? 'selected' : ''}}
>
@lang($option['title'])
Expand All @@ -160,34 +156,41 @@ class="text-gray-600 dark:text-gray-300"
@elseif ($field['type'] == 'multiselect')
@php $selectedOption = core()->getConfigData($nameKey, $currentChannel->code, $currentLocale->code) ?? ''; @endphp

<x-admin::form.control-group.control
type="select"
:name="$name"
:id="$name"
:rules="$validations"
:label="trans($field['title'])"
<v-field
name="{{ $name }}[]"
id="{{ $name }}"
rules="{{ $validations }}"
label="{{ trans($field['title']) }}"
multiple
>
@if (isset($field['repository']))
@foreach ($value as $key => $option)

<option value="{{ $key }}" {{ in_array($key, explode(',', $selectedOption)) ? 'selected' : ''}}>
@lang($value[$key])
</option>

@endforeach
@else
@foreach ($field['options'] as $option)
@php
$value = ! isset($option['value']) ? null : ( $value = ! $option['value'] ? 0 : $option['value'] );
@endphp
<select
name="{{ $name }}[]"
class="flex w-full min-h-[39px] py-2 px-3 border rounded-md text-sm text-gray-600 dark:text-gray-300 transition-all hover:border-gray-400 dark:hover:border-gray-400 focus:border-gray-400 dark:focus:border-gray-400 dark:bg-gray-900 dark:border-gray-800"
:class="[errors['{{ $name }}[]'] ? 'border border-red-600 hover:border-red-600' : '']"
multiple
>
@if (isset($field['repository']))
@foreach ($value as $key => $option)
<option
value="{{ $key }}"
{{ in_array($key, explode(',', $selectedOption)) ? 'selected' : ''}}
>
{{ trans($value[$key]) }}
</option>
@endforeach
@else
@foreach ($field['options'] as $option)
<option
value="{{ $value = $option['value'] ?? 0 }}"
{{ in_array($value, explode(',', $selectedOption)) ? 'selected' : ''}}
>
@lang($option['title'])
</option>
@endforeach
@endif
</select>
</v-field>

<option value="{{ $value }}" {{ in_array($option['value'], explode(',', $selectedOption)) ? 'selected' : ''}}>
@lang($option['title'])
</option>
@endforeach
@endif
</x-admin::form.control-group.control>

<!-- Boolean/Switch input -->
@elseif ($field['type'] == 'boolean')
Expand Down

0 comments on commit 530fc29

Please sign in to comment.