finalization of adding e-mail in mini-crud

This commit is contained in:
Alexis Gousseau 2022-10-12 16:44:28 +02:00
parent 6b096945cb
commit 870672f764
3 changed files with 39 additions and 7 deletions

View file

@ -71,11 +71,16 @@ abstract class UpdateMiniCrudRequest extends FormRequest
]);
break;
case InputType::string()->value:
case InputType::email()->value:
$rules = array_merge($rules, [
"data.$iptName.value" => $this->compileValidate('required|string|min:1', $input)
]);
break;
case InputType::email()->value:
$rules = array_merge($rules, [
"data.$iptName.value" =>
$this->compileValidate('required|email:rfc,strict,dns,spoof,filter', $input)
]);
break;
case InputType::text()->value:
$mergeRules = $this->compileValidate('required|string|min:10', $input);
$mergeRules = collect($mergeRules)

View file

@ -63,6 +63,7 @@ trait MiniCrudModel
case InputType::boolean()->value:
case InputType::text()->value:
case InputType::number()->value:
case InputType::email()->value:
case InputType::string()->value:
case InputType::videoVimeo()->value:
break;

View file

@ -26,7 +26,7 @@
@include('back.modules.input-error', [
'inputName' => 'data[{{$k}}][value]',
'helperId' => '{{$k}}StringHelp',
'helper' => $input['helper'],
'helper' => $input['helper'] ?? '',
])
</div>
</div>
@ -55,7 +55,7 @@
@include('back.modules.input-error', [
'inputName' => 'data[{{$k}}][value]',
'helperId' => '{{$k}}NumberHelp',
'helper' => $input['helper'],
'helper' => $input['helper'] ?? '',
])
</div>
</div>
@ -89,7 +89,7 @@
@include('back.modules.input-error', [
'inputName' => 'data[{{$k}}][text]',
'helperId' => '{{$k}}TextHelp',
'helper' => $input['helper'],
'helper' => $input['helper'] ?? '',
])
</div>
</div>
@ -119,7 +119,7 @@
@include('back.modules.input-error', [
'inputName' => 'data[{{$k}}][value]',
'helperId' => '{{$k}}BooleanHelp',
'helper' => $input['helper'],
'helper' => $input['helper'] ?? '',
])
</label>
</div>
@ -202,10 +202,36 @@
</div>
@break
@case(App\Enums\InputType::email()->value)
<div class="row">
<div class="col">
<fieldset class="border p-3 mb-3">
<div class="d-flex flex-row justify-content-start align-items-center mb-2">
<legend class="w-auto m-0">{{ $input['label'] }}</legend>
@if(!empty($input['tooltip']))
<span class="ms-1" data-bs-toggle="tooltip" data-bs-html="true" title="{{ $input['tooltip'] }}">
<i class="fa fa-question-circle"></i>
</span>
@endif
</div>
<div class="row mb-3">
<div class="form-group">
<input id="{{$k}}" type="email" class="form-control" name="data[{{$k}}][value]"
placeholder="{{ $input['label'] }}" value="{{ old("data.$k.value") ?? ($input['value'] ?? '') }}" required>
@include('back.modules.input-error', [
'inputName' => 'data[{{$k}}][value]',
'helperId' => '{{$k}}StringHelp',
'helper' => $input['helper'] ?? '',
])
</div>
</div>
</fieldset>
</div>
</div>
@break
@case(App\Enums\InputType::imageArray()->value)
@case(App\Enums\InputType::labelArray()->value)
@default
@php throw new Exception('Input type not handled'); @endphp
@endswitch