I can put select with icon in this code
{{ Form::select('country_id', array_column($countries->toarray(), 'name', 'id'), null, ['id'=>'country_id','data-te-select-placeholder'=> old('country_id') ? false : __('messages_admin.country'),], [1 => ['data-te-select-icon="https://tecdn.b-cdn.net/img/Photos/Avatars/avatar-4.webp"']]) }}
but I cannot put an image in my project like
{{ Form::select('country_id', array_column($countries->toarray(), 'name', 'id'), null, ['id'=>'country_id','data-te-select-placeholder'=> old('country_id') ? false : __('messages_admin.country'),], [1 => ['data-te-select-icon={{ asset('vendor/blade-flags/country-vi.svg') }}']]) }}
the error I got:
syntax error, unexpected identifier "vendor", expecting "]"
Update: I tried and it worked
[1 => ["data-te-select-icon=/public/vendor/blade-flags/country-us.svg"]]
because the input just sets the image for the first option and if I wanna set for all option I must do this
[
1 => ["data-te-select-icon=/public/vendor/blade-flags/country-us.svg"],
2 => ["data-te-select-icon=/public/vendor/blade-flags/country-us.svg"],
3 => ["data-te-select-icon=/public/vendor/blade-flags/country-us.svg"],
...
]
Is there any way to do a foreach like the code behind
[
<?php
foreach ($countries as $key => $country)echo ($key+1) . ' => ["data- te-select-icon=/public/vendor/blade-flags/country-vn.svg"]' . ',';
?>
]
I tried but it just print the text:
{{ Form::select('country_id', array_column($countries->toarray(), 'name', 'id'), null, ['id'=>'country_id', 'data-te-class-select-option-icon' => 'w-7 h-7 rounded', 'data-te-select-placeholder'=> old('country_id') ? false : __('messages_admin.country'),'class' => 'peer block min-h-[auto] w-full rounded border-0 bg-transparent px-3 py-[0.32rem] leading-[1.6] outline-none transition-all duration-200 ease-linear focus:placeholder:opacity-100 peer-focus:text-primary data-[te-input-state-active]:placeholder:opacity-100 motion-reduce:transition-none dark:text-black dark:placeholder:text-black dark:peer-focus:text-primary [&:not([data-te-input-placeholder-active])]:placeholder:opacity-0', 'data-te-select-init', 'data-te-select-filter="true"','data-te-class-select-input="peer block min-h-[auto] w-full rounded border-0 bg-transparent outline-none transition-all duration-200 ease-linear focus:placeholder:opacity-100 data-[te-input-state-active]:placeholder:opacity-100 motion-reduce:transition-none dark:text-black dark:placeholder:text-gray-200 [&:not([data-te-input-placeholder-active])]:placeholder:opacity-0 cursor-pointer data-[te-input-disabled]:bg-[#e9ecef] data-[te-input-disabled]:cursor-default group-data-[te-was-validated]/validation:mb-4 dark:data-[te-input-disabled]:bg-zinc-600"'], [
1 => ["data-te-select-icon=/public/vendor/blade-flags/country-vn.svg"],
2 => ["data-te-select-icon=/public/vendor/blade-flags/country-vn.svg"],
3 => ["data-te-select-icon=/public/vendor/blade-flags/country-vn.svg"],
4 => ["data-te-select-icon=/public/vendor/blade-flags/country-vn.svg"],
5 => ["data-te-select-icon=/public/vendor/blade-flags/country-vn.svg"],
6 => ["data-te-select-icon=/public/vendor/blade-flags/country-vn.svg"],
7 => ["data-te-select-icon=/public/vendor/blade-flags/country-vn.svg"],
8 => ["data-te-select-icon=/public/vendor/blade-flags/country-vn.svg"],
9 => ["data-te-select-icon=/public/vendor/blade-flags/country-vn.svg"],
10 => ["data-te-select-icon=/public/vendor/blade-flags/country-vn.svg"],
11 => ["data-te-select-icon=/public/vendor/blade-flags/country-vn.svg"],
12 => ["data-te-select-icon=/public/vendor/blade-flags/country-vn.svg"],
13 => ["data-te-select-icon=/public/vendor/blade-flags/country-vn.svg"],
14 => ["data-te-select-icon=/public/vendor/blade-flags/country-vn.svg"],
15 => ["data-te-select-icon=/public/vendor/blade-flags/country-vn.svg"],
16 => ["data-te-select-icon=/public/vendor/blade-flags/country-vn.svg"],
17 => ["data-te-select-icon=/public/vendor/blade-flags/country-vn.svg"],
18 => ["data-te-select-icon=/public/vendor/blade-flags/country-vn.svg"],
19 => ["data-te-select-icon=/public/vendor/blade-flags/country-vn.svg"],
20 => ["data-te-select-icon=/public/vendor/blade-flags/country-vn.svg"],
21 => ["data-te-select-icon=/public/vendor/blade-flags/country-vn.svg"],
22 => ["data-te-select-icon=/public/vendor/blade-flags/country-vn.svg"],
23 => ["data-te-select-icon=/public/vendor/blade-flags/country-vn.svg"],
...
Update: I also tried and put the $options into "[]" but not thing appear
@php$options = [];foreach ($countries as $key => $country)$options[] = ($key+1) . ' => ["data-te-select-icon=/public/vendor/blade-flags/country-vn.svg"]' . ',';
$options = implode($options);
@endphp
Please help me fix this, many thanks !