79230768

Date: 2024-11-27 14:53:24
Score: 1
Natty:
Report link

Probably the best way to dynamically add components in your template is the "Dynamic Components" feature native of Laravel:

@foreach ($fields as $field => $param)
    <x-dynamic-component
        :component="sprintf('larastrap::%s', $param['type'])"
        :params="[
            'name' => $field, 
            'label' => $param['label'], 
            'options' => $param['options'] ?? null
        ]"
    />
@endforeach

This approach is also mentioned in the Larastrap documentation.

Reasons:
  • Contains signature (1):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: madbob