mirror of
https://github.com/grokability/snipe-it.git
synced 2026-03-12 17:52:00 +08:00
Migrate countries macro on user page
This commit is contained in:
35
resources/views/blade/input/country-select.blade.php
Normal file
35
resources/views/blade/input/country-select.blade.php
Normal 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>
|
||||
@@ -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>') !!}
|
||||
|
||||
Reference in New Issue
Block a user