Migrate countries macro on user page

This commit is contained in:
Marcus Moore
2026-03-09 17:22:43 -07:00
parent 338fc88095
commit fa6adaa155
2 changed files with 40 additions and 1 deletions

View File

@@ -0,0 +1,35 @@
@props([
'name' => 'country',
'selected' => null,
])
@php
$countries_array = trans('localizations.countries');
@endphp
<select
name="{{ $name }}"
{{ $attributes->merge(['class' => 'select2']) }}
aria-label="{{ $name }}"
data-placeholder="{{ trans('localizations.select_country') }}"
data-allow-clear="true"
>
@foreach($countries_array as $abbreviation => $country)
@php
// We have to handle it this way to handle deprecation warnings since you can't strtoupper on null
if ($abbreviation!='') {
$abbreviation = strtoupper($abbreviation);
}
@endphp
<option value="{{ $abbreviation }}" {{ $selected === $abbreviation ? 'selected' : '' }}>
{{ $country }}
</option>
@endforeach
{{-- If the country value doesn't exist in the array, add it as a new option and select it so we don't drop that data --}}
@if (!array_key_exists($selected, $countries_array)) {
<option value="{{ e($selected) }}" selected="selected" role="option" aria-selected="true"> {{ e($selected) }} *</option> ';
@endif
</select>

View File

@@ -502,7 +502,11 @@
<div class="form-group{{ $errors->has('country') ? ' has-error' : '' }}">
<label class="col-md-3 control-label" for="country">{{ trans('general.country') }}</label>
<div class="col-md-6">
{!! Form::countries('country', old('country', $user->country), 'col-md-12 select2') !!}
<x-input.country-select
name="country"
:selected="old('country', $user->country)"
class="col-md-12"
/>
<p class="help-block">{{ trans('general.countries_manually_entered_help') }}</p>
{!! $errors->first('country', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}