F
Filament5mo ago
Yohan

Customise the modal form view

What's the best way to personalise the view of the forms inside modal? My exact context is that I'd like to add a video (youtube) at the very bottom of my form. This form is currently configured on my VariablesRelationManager class, which is responsible for managing my Variable relationship. class VariablesRelationManager extends RelationManager { protected static string $relationship = ‘variables’; public function form(Form $form): Form { return $form ->schema([ FormsComponentsTextInput::make(‘name’) ->required()
4 Replies
Yohan
YohanOP5mo ago
Thanks @Leandro Ferreira , but how do I pass data to the view attached to the ViewField? I need to dynamically retrieve the value of one of my select fields (to display the corresponding video)? FormsComponentsSelect::make(‘type’) ->options([ VariableType::TEXT->value => ‘Text’, VariableType::URL->value => ‘URL’, VariableType::IMAGE->value => ‘Image’, ]) ->required() ->live(),
LeandroFerreira
LeandroFerreira5mo ago
I think viewfield has an state
Select::make(‘type’)
...
->live()
->afterStateUpdated(function(Set $set, $state){
$set('custom_view', $state);
})
Select::make(‘type’)
...
->live()
->afterStateUpdated(function(Set $set, $state){
$set('custom_view', $state);
})
ViewField::make('custom_view') inside the view you can use {{ $getState() }}
Yohan
YohanOP5mo ago
You rock !! It works smoothly, thank you for your time @Leandro Ferreira !!
Want results from more Discord servers?
Add your server