@if(count($customFields))

{{ __('backend.custom_fields') }}

@php $fields_html = ''; foreach ($customFields as $field) { $model_value = $customFieldsValues[$field->id]??null; $fieldType = strtolower($field->field_type); $fieldName = str_replace(' ', '_', $field->field_name); // Replace spaces with underscores $fieldName = preg_replace('/[^A-Za-z0-9_]/', '', $fieldName); // Remove other special characters $fieldValue = (!empty($field->field_values) && $field->field_values != '[]') ? json_decode($field->field_values, true) : null; $attributes = $fieldType == 'dropdown' ? 'class="form-select "' :'class="form-control "'; // Initialize empty string for attributes if (!empty($custom_attr)) { foreach ($custom_attr as $key => $value) { $attributes .= " $key='$value'"; // Build attribute string } } $fields_html .= '
'; $fields_html .= ''; switch ($fieldType) { case 'dropdown': $model_value = ($model_value)? json_decode($model_value,1):''; // Implement your dropdown logic here, including options based on $fieldValue $fields_html .= '"; break; case 'checkbox': // Implement your dropdown logic here, including options based on $fieldValue $fields_html .= '
'; $model_value = json_decode($model_value,1); foreach ($fieldValue as $key => $value) { $selected = isset($model_value[$value]) ?'checked':''; $fields_html .= ''; } $fields_html .= "
"; break; default: $fields_html .= ''; } $fields_html .= '
'; } @endphp {!! $fields_html !!}
@endif