Skip to content

Commit df7ac48

Browse files
author
Marc Geurts
committed
Grouped Timezone select by continent
1 parent 245fc70 commit df7ac48

File tree

2 files changed

+35
-11
lines changed

2 files changed

+35
-11
lines changed

resources/views/auth/register.blade.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,20 @@
6565
</div>
6666
<div class="md:w-2/3">
6767
<select id="timezone" class="block w-full rounded-sm" name="timezone" required>
68-
@foreach (timezone_identifiers_list() as $timezone)
69-
<option value="{{ $timezone }}" @selected($timezone === old('timezone', config('app.timezone')))>{{ $timezone }}</option>
68+
@php
69+
$timezones = collect(timezone_identifiers_list())
70+
->groupBy(fn($tz) => str_contains($tz, '/') ? explode('/', $tz)[0] : 'Other')
71+
->sortKeys();
72+
@endphp
73+
74+
@foreach ($timezones as $continent => $zones)
75+
<optgroup label="{{ $continent }}">
76+
@foreach ($zones as $timezone)
77+
<option value="{{ $timezone }}" @selected($timezone === old('timezone', config('app.timezone')))>
78+
{{ str_replace('_', ' ', $timezone) }}
79+
</option>
80+
@endforeach
81+
</optgroup>
7082
@endforeach
7183
</select>
7284
</div>

resources/views/profile/update-profile-information-form.blade.php

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
{{-- profile photo file input --}}
1919
<input type="file" id="photo" class="hidden" wire:model.live="photo" x-ref="photo"
2020
x-on:change="
21-
photoName = $refs.photo.files[0].name;
22-
const reader = new FileReader();
23-
reader.onload = (e) => {
24-
photoPreview = e.target.result;
25-
};
26-
reader.readAsDataURL($refs.photo.files[0]);
27-
" />
21+
photoName = $refs.photo.files[0].name;
22+
const reader = new FileReader();
23+
reader.onload = (e) => {
24+
photoPreview = e.target.result;
25+
};
26+
reader.readAsDataURL($refs.photo.files[0]);
27+
" />
2828

2929
<x-label for="photo" value="{{ __('user.photo') }} :" />
3030

@@ -103,8 +103,20 @@
103103
<div class="col-span-6 md:col-span-4">
104104
<x-label for="timezone" value="{{ __('user.timezone') }} :" />
105105
<select id="timezone" class="block w-full mt-1 rounded-sm" name="timezone" wire:model="state.timezone" required>
106-
@foreach (timezone_identifiers_list() as $timezone)
107-
<option value="{{ $timezone }}" @selected(old('timezone') === $timezone)>{{ $timezone }}</option>
106+
@php
107+
$timezones = collect(timezone_identifiers_list())
108+
->groupBy(fn($tz) => str_contains($tz, '/') ? explode('/', $tz)[0] : 'Other')
109+
->sortKeys();
110+
@endphp
111+
112+
@foreach ($timezones as $continent => $zones)
113+
<optgroup label="{{ $continent }}">
114+
@foreach ($zones as $timezone)
115+
<option value="{{ $timezone }}" @selected(old('timezone') === $timezone)>
116+
{{ str_replace('_', ' ', $timezone) }}
117+
</option>
118+
@endforeach
119+
</optgroup>
108120
@endforeach
109121
</select>
110122
</div>

0 commit comments

Comments
 (0)