F
Filament2w ago
CGM

Testing Builders

Using Builder Fields, how can I test that a builder block has certain fields visible and if specific sub-fields are required? https://filamentphp.com/docs/3.x/forms/fields/builder#testing-builders Take this mockup for example:
Builder::make('schema.elements')
->label('Elements')
->addActionLabel('Add Form Element')
->blocks([
Builder\Block::make('textarea')
->label('Textarea')
->icon('heroicon-o-document-text')
->schema([
TextInput::make('label')->required(),
TextInput::make('field')->required(),
TextInput::make('placeholder'),
Textarea::make('helper_text')->rows(2),
Textarea::make('default_value')->rows(3),
TextInput::make('rows')->numeric()->default(3),
Toggle::make('is_required'),
])->columns(2),
Builder\Block::make('rich_editor')
->label('Rich Editor')
->icon('heroicon-o-pencil-square')
->schema([
TextInput::make('label')->required(),
TextInput::make('field')->required(),
Textarea::make('helper_text'),
RichEditor::make('default_value'),
Toggle::make('is_required'),
])->columns(2),
])
Builder::make('schema.elements')
->label('Elements')
->addActionLabel('Add Form Element')
->blocks([
Builder\Block::make('textarea')
->label('Textarea')
->icon('heroicon-o-document-text')
->schema([
TextInput::make('label')->required(),
TextInput::make('field')->required(),
TextInput::make('placeholder'),
Textarea::make('helper_text')->rows(2),
Textarea::make('default_value')->rows(3),
TextInput::make('rows')->numeric()->default(3),
Toggle::make('is_required'),
])->columns(2),
Builder\Block::make('rich_editor')
->label('Rich Editor')
->icon('heroicon-o-pencil-square')
->schema([
TextInput::make('label')->required(),
TextInput::make('field')->required(),
Textarea::make('helper_text'),
RichEditor::make('default_value'),
Toggle::make('is_required'),
])->columns(2),
])
How can I setup a simple test to load the form, add one of these blocks to the Element and then test that certain sub-fields are both visible and maybe required?
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?