@php ($attributes = (isset($value['attributes']) ? $value['attributes'] : [])) @php ($attributes['id'] = (isset($attributes['id']) ? $attributes['id'] : $key)) @php ($attributes['class'] = (isset($attributes['class']) ? $attributes['class'] : 'form-control form-control-lg')) @php ($attributes['class'] .= ($errors->has($key) ? ' is-invalid' : '')) @php ($floatOff = ['file', 'radio', 'checkbox', 'editor', 'custom', 'switch']) @php ($labelWidth = (isset($value['label_width']) ? $value['label_width'] : 'col-lg-3 col-md-6 col-sm-6 col-xs-12 text-right')) @php ($fieldWidth = (isset($value['field_width']) ? $value['field_width'] : 'col-12')) @php ($value['value'] = isset($value['value']) ? $value['value'] : null) @if($coverClass)
@endif
@if(isset($value['label']) && $value['label']) @endif @if(isset($value['help']) && $value['help']) @endif @if($value['type'] != 'anchor') @if(isset($value['icon']) && $value['icon']) @endif @endif @if($value['type'] == 'text') {!! html()->text($key, $inputValue)->attributes($attributes) !!} @elseif($value['type'] == 'color') {!! html()->input('color', $key, $inputValue ?? '#ffffff')->attributes($attributes) !!} @elseif($value['type'] == 'text_with_prefix')
@if(isset($value['prefix']) && $value['prefix']) @if($value['prefix']['type'] == 'select') {!! html()->select($value['prefix']['name'], $value['prefix']['options'], $value['prefix']['value'])->attributes($value['prefix']['attributes']) !!} @endif @endif {!! html()->text($key, $inputValue)->attributes($attributes) !!}
@elseif($value['type'] == 'label') @php ($attributes['readonly'] = 'true') @php ($attributes['disabled'] = 'true') {!! html()->text($key, $inputValue)->attributes($attributes) !!} @elseif($value['type'] == 'text_label') @if(isset($value['value']) && !empty($value['value']))
{{ $value['value'] }} @if(isset($value['attributes']['help']) && ((is_array($value['attributes']['help']) && array_key_exists($k, $value['attributes']['help']) && $value['attributes']['help'][$k]) || (is_string($value['attributes']['help']) && $value['attributes']['help']))) @endif
@endif @elseif($value['type'] == 'email') {!! html()->email($key, $inputValue)->attributes($attributes) !!} @elseif($value['type'] == 'number') {!! html()->number($key, $inputValue)->attributes($attributes) !!} @elseif($value['type'] == 'date') {{-- @php($attributes['class'] .= ' datepicker') --}} {!! html()->date($key, $inputValue)->attributes($attributes) !!} @elseif($value['type'] == 'time') {{-- */ @php($attributes['class'] .= ' timepicker') --}} {!! html()->time($key, $inputValue)->attributes($attributes) !!} @elseif($value['type'] == 'datetime') {{-- @php($attributes['class'] .= ' datetimepicker') --}} {!! html()->datetime($key, $inputValue)->attributes($attributes) !!} @elseif($value['type'] == 'password') {!! html()->password($key)->attributes($attributes) !!} @elseif($value['type'] == 'textarea') {!! html()->textarea($key, $inputValue)->attributes($attributes) !!} @elseif($value['type'] == 'editor') @php ($attributes['class'] .= ' editor') {!! html()->textarea($key, $inputValue)->attributes($attributes) !!} @once @push('page_script') @endpush @endonce @elseif($value['type'] == 'select') @php($attributes['class'] = (!isset($attributes['class']) || strpos($attributes['class'], 'select2') === false) ? $attributes['class'] . ' select2' : $attributes['class']) @if(is_array($value['options']) && !empty($value['options'])) @php($value['options'] = $value['options']) @endif {!! html()->select($key, $value['options'], $value['value'])->attributes($attributes) !!} @elseif($value['type'] == 'select_with_optgroups') @php($selectAttributes = isset($value['attributes']) ? $value['attributes'] : []) @php($selectAttributes['class'] = isset($selectAttributes['class']) ? $selectAttributes['class'] : 'form-control form-control-lg select2') @php($formattedOptions = []) @php( is_array($value['options']) && !empty($value['options']) ? array_walk($value['options'], function($option) use (&$formattedOptions) { if(isset($option['children']) && is_array($option['children']) && !empty($option['children'])) { $formattedOptions[$option['label']] = $option['children']; } }) : null ) @if(isset($selectAttributes['multiple']) && $selectAttributes['multiple']) {!! html()->select($key, $formattedOptions, $value['value'])->multiple()->attributes($selectAttributes) !!} @else {!! html()->select($key, $formattedOptions, $value['value'])->attributes($selectAttributes) !!} @endif @elseif($value['type'] == 'multiselect') @php($attributes['multiple'] = 'true') @php($attributes['class'] .= ' select2') {!! html()->select($key, $value['options'], $value['value'])->multiple()->attributes($attributes) !!} @elseif($value['type'] == 'copy_mapping') @php( $fromOptions = isset($value['from_options']) ? $value['from_options'] : $value['options'] ?? [] ) @php( $toOptions = isset($value['to_options']) ? $value['to_options'] : $value['options'] ?? [] ) @php( $mappings = isset($value['value']) ? (is_array($value['value']) ? $value['value'] : []) : [] ) @php( $firstMapping = !empty($mappings) ? $mappings[0] : ['from' => '', 'to' => ''] )
@elseif($value['type'] == 'tag') @php($attributes['data-live-search'] = "true") @php($attributes['data-size'] = 5) @if(!isset($attributes['plain']) || (isset($attributes['plain']) && $attributes['plain'])) @php($attributes['class'] .= ' tags-input') @endif @if(is_array($value['options']) && !empty($value['options'])) @php($value['options'] = $value['options']) @endif {!! html()->select($key, $value['options'], $inputValue)->attributes($attributes) !!} @elseif($value['type'] == 'autocomplete') @php($attributes['class'] .= ' select2-ajax-autocomplete') @php($selectedOptions = []) @if(is_array($inputValue) && !empty($inputValue)) @foreach($inputValue as $selectedId) @php($selectedOptions[$selectedId] = 'Loading...') {{-- Will be populated by JS --}} @endforeach @endif {!! html()->select($key, $selectedOptions, $inputValue)->attributes($attributes) !!} @once @push('page_script') @endpush @endonce @elseif($value['type'] == 'tag-custom') @php($attributes['class'] .= ' tags-input') @php($attributes['data-role'] = 'tagsinput') {!! html()->text($key, $inputValue)->attributes($attributes) !!} @once @push('page_css') @endpush @push('page_script') @endpush @endonce @elseif($value['type'] == 'radio')
@foreach($value['options'] as $k => $option)
{{ html() ->radio($key) ->value($k) ->checked($value['value'] == $k ? true : false) ->attributes([ 'class' => $key .' custom-control-input', 'id' => $key . '-' . $k, 'name' => isset($value['attributes']['name']) ? $value['attributes']['name'] : $key, ]) }}
@endforeach
@elseif($value['type'] == 'checkbox')
@foreach($value['options'] as $k => $option)
@php( $checkboxAttributes = [ 'class' => $key .' custom-control-input ' . (isset($value['attributes']['class']) ? $value['attributes']['class'] : ''), 'id' => $key . '-' . $k, ] ) @if (isset($value['attributes']['disabled']) && is_array($value['attributes']['disabled']) && array_key_exists($k, $value['attributes']['disabled']) && $value['attributes']['disabled'][$k]) @php($checkboxAttributes['disabled'] = 'disabled') @elseif (isset($value['attributes']['disabled']) && $value['attributes']['disabled'] === true) @php($checkboxAttributes['disabled'] = 'disabled') @endif {{ html() ->checkbox(isset($value['attributes']['name']) ? $value['attributes']['name'] : $key .'[]') ->value($k) ->checked((is_array($value['value']) && in_array($k, $value['value'])) ? true : false) ->attributes($checkboxAttributes) }} @if(isset($value['attributes']['help']) && ((is_array($value['attributes']['help']) && array_key_exists($k, $value['attributes']['help']) && $value['attributes']['help'][$k]) || (is_string($value['attributes']['help']) && $value['attributes']['help']))) @endif
@endforeach
@elseif($value['type'] == 'switch')
@foreach($value['options'] as $k => $option)
{{ $option }}
@endforeach
@elseif($value['type'] == 'color')
{!! html()->text($key, $inputValue)->attributes($attributes) !!}
@once @push('page_css') @endpush @push('page_script') @endpush @endonce @elseif($value['type'] == 'dropzone') @php($maxFiles = isset($value['attributes']['max_files']) ? $value['attributes']['max_files'] : 1) @php($isSingleFile = $maxFiles == 1) @php($acceptedFileTypes = isset($value['attributes']['accepted_file_types']) ? $value['attributes']['accepted_file_types'] : 'jpeg,jpg,png,pdf,doc,docx') @php($cropperEnabled = isset($value['attributes']['cropper']) && $value['attributes']['cropper']) @php($placeholder = $value['attributes']['placeholder'] ?? 'your files') @php($buttonText = $value['button_text'] ?? 'BROWSE') @php( $acceptedMimeTypes = implode(',', array_map(function($ext) { return '.'.trim($ext); }, explode(',', $acceptedFileTypes))) )

Drag and drop {{ $placeholder }} here to upload, or

@once @push('page_css') @endpush @endonce @push('page_script') @once @endonce @endpush @elseif($value['type'] == 'file') @php ($fileInputName = $key) @if(array_key_exists("cropper", $attributes) && $attributes['cropper']) @php ($cropRatio = (isset($attributes['ratio']) && $attributes['ratio']) ? $attributes['ratio'] : '400x300') @php ($attributes['onclick'] = "readImage(this, '". $cropRatio ."')") @php ($fileInputName .= '_input') @endif @if(!isset($attributes['id'])) @php ($attributes['id'] = $key) @endif @php ($attributes['class'] .= ' custom-file-input') @if(isset($attributes['multiple']) && $attributes['multiple']) @once @push('page_script') @endpush @endonce @else @php($originalFileName = '') @if($value['value'] && isset($value['value']['file_name_original'])) @php($originalFileName = $value['value']['file_name_original']) @endif @php($value['value'] = isset($value['value']['original']) ? $value['value'] : \App\Models\Masters\File::file($value['value'])) @if(array_key_exists("preview", $attributes) && $attributes['preview']) @php ($attributes['onchange'] = "readImage(this)") @endif {{-- Append unified preview handler (keeps any existing onchange like cropper) --}} @php ($attributes['onchange'] = isset($attributes['onchange']) ? rtrim($attributes['onchange'], ';') . ';handleSingleFileUnifiedPreview(this)' : 'handleSingleFileUnifiedPreview(this)')
{!! html()->file($fileInputName)->attributes($attributes) !!}
@if($value['value']['file_mime']) @if(in_array($value['value']['file_mime'], \App\Models\Masters\File::$fileValidations['image']['file_mimes'])) preview @else @endif @endif
{{ $originalFileName }}
@if($value['value']['file_mime']) @endif {{-- --}}

{{ isset($attributes['placeholder']) ? $attributes['placeholder'] : "Upload " . $value['label'] }}

@once @push('page_script') @endpush @endonce @if(isset($value['help'])) {!! $value['help'] !!} @endif @endif @elseif($value['type'] == 'custom') {!! $value['value'] !!} @elseif($value['type'] == 'anchor') @endif
@if ($errors->has($key)) @endif
@if($coverClass)
@endif