F
Filament14mo ago
erigra.

Creating global blocks?

Is it possible to create global blocks using the Blocks, that can then be attached to different Resources? Example:
Builder\Block::make('address')
->schema([
TextInput::make('street')
->label('Street')
->required(),
TextInput::make('zipcode')
->label('Zipcode')
->required(),
])
Builder\Block::make('address')
->schema([
TextInput::make('street')
->label('Street')
->required(),
TextInput::make('zipcode')
->label('Zipcode')
->required(),
])
And then I can simply add an address block to different resources? If so where would the block be defined, and how would it be attached? I can't find anything about this in docs.
Solution:
Yes, there are several ways to do this. It’s standard OOP principles and you can store them anywhere you want.
Jump to solution
3 Replies
Solution
awcodes
awcodes14mo ago
Yes, there are several ways to do this. It’s standard OOP principles and you can store them anywhere you want.
awcodes
awcodes14mo ago
For example: https://gist.github.com/awcodes/0ca10c437de1bfdf03d13b19326d6aaf Then just use it in your Builder component
->blocks([
HeroBlock::make()
])
->blocks([
HeroBlock::make()
])
Gist
CustomFilamentBlock
CustomFilamentBlock. GitHub Gist: instantly share code, notes, and snippets.
erigra.
erigra.OP14mo ago
@awcodes Ah, that makes a lot of sense, huge thanks!
Want results from more Discord servers?
Add your server