@foreach ($fields as $k => $field)
@php
$key = $tabKey ? "{$tabKey}_{$k}_{$i}" : "{$k}_{$i}";
$name = $i <= $current ? $key : '';
$title = Arr::get($field, 'title');
$placeholder = Arr::get($field, 'placeholder', $title);
$defaultValue = Arr::get($field, 'value', Arr::get($field, 'default_value'));
$value = Arr::get($attributes, $key, $defaultValue);
$fieldAttributes = [...Arr::get($field, 'attributes', []), 'data-name' => $key];
$options = [];
if (Arr::has($field, 'options')) {
$options = Arr::get($field, 'options', []);
}
@endphp
@switch(Arr::get($field, 'type'))
@case('image')
{!! Form::mediaImage($name, $value, $fieldAttributes) !!}
@break
@case('file')
{!! Form::mediaFile($name, $value, $fieldAttributes) !!}
@break
@case('color')
{!! Form::customColor($name, $value, $fieldAttributes) !!}
@break
@case('icon')
{!! Form::themeIcon($name, $value, $fieldAttributes) !!}
@break
@case('number')
{!! Form::number($name, $value, [
'class' => 'form-control',
'placeholder' => $placeholder,
'data-name' => $key,
]) !!}
@break
@case('textarea')
{!! Form::textarea($name, $value, [
'class' => 'form-control',
'placeholder' => $placeholder,
'rows' => 3,
...$fieldAttributes,
]) !!}
@break
@case('checkbox')
@php($options = ['no' => __('No'), 'yes' => __('Yes')])
@case('select')
{!! Form::customSelect($name, $options, $value, $fieldAttributes) !!}
@break
@case('onOff')
{!! Form::onOff($name, $value, [...$options, ...$fieldAttributes]) !!}
@break
@case('coreIcon')
{!! Form::coreIcon($name, $value, [...$options, ...$fieldAttributes]) !!}
@break
@default
{!! Form::text($name, $value, [
'class' => 'form-control',
'placeholder' => $placeholder,
...$fieldAttributes,
]) !!}
@endswitch
@if ($helper = Arr::get($field, 'helper'))
{{ Form::helper($helper) }}
@endif
@endforeach