More compoonents for forms, enable select forms to have a read only appearance
This commit is contained in:
parent
83bdea458f
commit
3a12ec005e
@ -1,3 +1,3 @@
|
||||
<x-leenooks::form.base {{ $attributes }}>
|
||||
<input type="email" class="form-control {{ $classes ?? ''}}@error($name) is-invalid @enderror" id="{{ $id ?? $name }}" name="{{ $name }}" value="{{ old($name,$value ?? '') }}">
|
||||
<input type="email" class="form-control {{ $classes ?? ''}}@error($name) is-invalid @enderror" id="{{ $id ?? $name }}" name="{{ $name }}" value="{{ old($name,$value ?? '') }}" @readonly(isset($readonly)) @required(isset($required))>
|
||||
</x-leenooks::form.base>
|
@ -1,3 +1,3 @@
|
||||
<x-leenooks::form.base {{ $attributes }}>
|
||||
<input type="password" class="form-control {{ $classes ?? ''}}@error($name) is-invalid @enderror" id="{{ $id ?? $name }}" name="{{ $name }}" value="{{ old($name,$value ?? '') }}">
|
||||
<input type="password" class="form-control {{ $classes ?? ''}}@error($name) is-invalid @enderror" id="{{ $id ?? $name }}" name="{{ $name }}" value="{{ old($name,$value ?? '') }}" @readonly(isset($readonly)) @required(isset($required))>
|
||||
</x-leenooks::form.base>
|
@ -1,4 +1,5 @@
|
||||
<x-leenooks::form.base {{ $attributes }}>
|
||||
<input type="hidden" id="{{ $name }}_disabled" name="{{ $name }}" value="" disabled>
|
||||
<select class="form-control @error($name) is-invalid @enderror" id="{{ $id }}" name="{{ $name }}">
|
||||
@if(isset($addvalues) && $addvalues)
|
||||
<option id="new"></option>
|
||||
@ -27,6 +28,18 @@
|
||||
@js(select2,autofocus)
|
||||
|
||||
<script type="text/javascript">
|
||||
// Select doesnt support read only so we'll use disable and a new field
|
||||
function {{$id}}_readonly(on) {
|
||||
if (on) {
|
||||
$('#{{ $name }}').prop('disabled',true);
|
||||
$('#{{ $name }}_disabled').prop('disabled',false).val($('#{{ $name }}').val());
|
||||
|
||||
} else {
|
||||
$('#{{ $name }}').prop('disabled',false);
|
||||
$('#{{ $name }}_disabled').prop('disabled',true);
|
||||
}
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
$('#{{ $id }}').select2({
|
||||
dropdownAutoWidth: true,
|
||||
|
Loading…
Reference in New Issue
Block a user