F
Filament3mo ago
lbar

extraAttributes add class on Section seems not works

hi! actually i have a form section like this:
Section::make()
->description('Main Contact Referent')
->relationship('user')
->schema([
TextInput::make('firstname')
->label('First Name')
->formatStateUsing(fn($record) => $record->mainMember ? $record->mainMember->firstname : null)
->disabled(),
TextInput::make('lastname')
->label('Last Name')
->formatStateUsing(fn($record) => $record->mainMember ? $record->mainMember->lastname : null)
->disabled(),
TextInput::make('tax_code')
->label('Tax Code')
->disabled(),
])
->collapsed()
->extraAttributes(['class' => 'bg-neutral-950']),
Section::make()
->description('Main Contact Referent')
->relationship('user')
->schema([
TextInput::make('firstname')
->label('First Name')
->formatStateUsing(fn($record) => $record->mainMember ? $record->mainMember->firstname : null)
->disabled(),
TextInput::make('lastname')
->label('Last Name')
->formatStateUsing(fn($record) => $record->mainMember ? $record->mainMember->lastname : null)
->disabled(),
TextInput::make('tax_code')
->label('Tax Code')
->disabled(),
])
->collapsed()
->extraAttributes(['class' => 'bg-neutral-950']),
the class added on the html appear correctly, but nothing change from the rendered html. I basically want change a background for a specific section of this form. Is that a correct approach? ty
Solution:
it was not rendered at all. actually i have solved creating a custom theme and there creating a class like ``` .mycustom-background { @apply bg-neutral-950 !important; }...
Jump to solution
5 Replies
lbar
lbarOP3mo ago
that's the way that html of this section appear. but no custom background found
No description
toeknee
toeknee3mo ago
Inspect the browser, is that color overrride by any chance or actually just not rendereD?
Solution
lbar
lbar3mo ago
it was not rendered at all. actually i have solved creating a custom theme and there creating a class like
.mycustom-background {
@apply bg-neutral-950 !important;
}
.mycustom-background {
@apply bg-neutral-950 !important;
}
and then
->extraAttributes(['class' => 'mycustom-background']),
->extraAttributes(['class' => 'mycustom-background']),
But to me this seems an overkill. not sure if this is the best approach to do this. So before to mark it solved, i just wait for some others opinions.
toeknee
toeknee3mo ago
You could have just used style
lbar
lbarOP3mo ago
yes, found also that one. but at the end of the day I prefer the custom theme, in order to be little bit more organized. thank you
Want results from more Discord servers?
Add your server