Handle dynamic fields on frontend

This commit is contained in:
Benjamin Beganović 2021-10-04 12:33:52 +02:00
parent a345452c5e
commit 166e27c7bd

View File

@ -12,14 +12,88 @@
<form action="{{ route('client.register', request()->route('company_key')) }}" method="POST" x-data="{ more: false }">
@csrf
@include('portal.ninja2020.auth.includes.register.personal_information')
<span class="block mt-4 text-gray-800 hover:text-gray-900 text-right cursor-pointer" x-on:click="more = !more">{{ ctrans('texts.more_fields') }}</span>
<div class="grid grid-cols-12 gap-4 mt-10">
@foreach($company->client_registration_fields as $field)
<div class="col-span-12 md:col-span-6">
<section class="flex items-center">
<label
for="{{ $field['key'] }}"
class="input-label">
{{ ctrans("texts.{$field['key']}") }}
</label>
@if($field['required'])
<section class="text-red-400 ml-1 text-sm">*</section>
@endif
</section>
<div x-show="more">
@include('portal.ninja2020.auth.includes.register.website')
@include('portal.ninja2020.auth.includes.register.personal_address')
@include('portal.ninja2020.auth.includes.register.shipping_address')
@if($field['key'] === 'email')
<input
id="{{ $field['key'] }}"
class="input w-full"
type="email"
name="{{ $field['key'] }}"
{{ $field['required'] ? 'required' : '' }} />
@elseif($field['key'] === 'password')
<input
id="{{ $field['key'] }}"
class="input w-full"
type="password"
name="{{ $field['key'] }}"
{{ $field['required'] ? 'required' : '' }} />
@elseif($field['key'] === 'country_id')
<select
id="shipping_country"
class="input w-full form-select"
name="shipping_country">
<option value="none"></option>
@foreach(App\Utils\TranslationHelper::getCountries() as $country)
<option
{{ $country == isset(auth()->user()->client->shipping_country->id) ? 'selected' : null }} value="{{ $country->id }}">
{{ $country->iso_3166_2 }}
({{ $country->name }})
</option>
@endforeach
</select>
@else
<input
id="{{ $field['key'] }}"
class="input w-full"
name="{{ $field['key'] }}"
{{ $field['required'] ? 'required' : '' }} />
@endif
@error($field['key'])
<div class="validation validation-fail">
{{ $message }}
</div>
@enderror
</div>
@if($field['key'] === 'password')
<div class="col-span-12 md:col-span-6">
<section class="flex items-center">
<label
for="password_confirmation"
class="input-label">
{{ ctrans('texts.password_confirmation') }}
</label>
@if($field['required'])
<section class="text-red-400 ml-1 text-sm">*</section>
@endif
</section>
<input
id="password_confirmation"
type="password"
class="input w-full"
name="password_confirmation"
{{ $field['required'] ? 'required' : '' }} />
</div>
@endif
@endforeach
</div>
<div class="flex justify-between items-center mt-8">