Passing multiple variables to a ViewField
What I'm using now:
This works just fine. Just wondering if others are doing / would do this differently...
ViewField::make('myViewField')
->formatStateUsing(function ($record) {
return [
'href' => route('requests.pdf', ['request' => $record]),
'caption' => __('request.pdf.link')
];
})
->view('forms.components.download') ViewField::make('myViewField')
->formatStateUsing(function ($record) {
return [
'href' => route('requests.pdf', ['request' => $record]),
'caption' => __('request.pdf.link')
];
})
->view('forms.components.download')<x-dynamic-component
:component="$getFieldWrapperView()"
:id="$getId()"
:label="$getLabel()"
:label-sr-only="$isLabelHidden()"
:helper-text="$getHelperText()"
:hint="$getHint()"
:hint-action="$getHintAction()"
:hint-color="$getHintColor()"
:hint-icon="$getHintIcon()"
:required="$isRequired()"
:state-path="$getStatePath()"
>
<div x-data="{ state: $wire.entangle('{{ $getStatePath() }}').defer }">
<a href="{{ $getState()['href'] }}" class="flex gap-1">
<x-icon-gmdi-file-download-o class="w-6 h-6"/>{{ $getState()['caption'] }}
</a>
</div>
</x-dynamic-component><x-dynamic-component
:component="$getFieldWrapperView()"
:id="$getId()"
:label="$getLabel()"
:label-sr-only="$isLabelHidden()"
:helper-text="$getHelperText()"
:hint="$getHint()"
:hint-action="$getHintAction()"
:hint-color="$getHintColor()"
:hint-icon="$getHintIcon()"
:required="$isRequired()"
:state-path="$getStatePath()"
>
<div x-data="{ state: $wire.entangle('{{ $getStatePath() }}').defer }">
<a href="{{ $getState()['href'] }}" class="flex gap-1">
<x-icon-gmdi-file-download-o class="w-6 h-6"/>{{ $getState()['caption'] }}
</a>
</div>
</x-dynamic-component>This works just fine. Just wondering if others are doing / would do this differently...