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
You could use a ViewField in your form schema
https://filamentphp.com/docs/3.x/forms/fields/custom#view-fields
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(),
I think viewfield has an state
ViewField::make('custom_view')
inside the view you can use {{ $getState() }}
You rock !! It works smoothly, thank you for your time @Leandro Ferreira !!