Merlijn01
Merlijn01
FFilament
Created by Merlijn01 on 3/28/2024 in #❓┊help
Spatie Media Library set alt text
I'm trying to set the alt text of an image in a form. I tried it using the custom properties, with a property 'alt_text'. It works when creating a new item, but I can't make an edit work.
Is setting the alt of an image using a custom property the way to go? Are there any alternatives? See my code below: As long as the image not changes, the alt_text does not update. Even if the alt_text_input differs from the current custom property alt_text value.
public static function form(Form $form): Form
{
return $form
->schema([
...
TextInput::make('alt_text_input')
->live()
->reactive()
->required(),
SpatieMediaLibraryFileUpload::make('image')
->collection('bar-images')
->imageEditor()
->customProperties(function (Get $get) {
return ['alt_text' => $get('alt_text_input')];
})
->afterStateHydrated(function (Get $get, Set $set, $state, $record) {
if( is_null($get('alt_text_input'))) {
if($record) {
if($record->getMedia('bar-images')->first()){
$set('alt_text_input', $record->getMedia("bar-images")->first()->custom_properties['alt_text']);
}
}
}
})
->image(),
...
]);
}
public static function form(Form $form): Form
{
return $form
->schema([
...
TextInput::make('alt_text_input')
->live()
->reactive()
->required(),
SpatieMediaLibraryFileUpload::make('image')
->collection('bar-images')
->imageEditor()
->customProperties(function (Get $get) {
return ['alt_text' => $get('alt_text_input')];
})
->afterStateHydrated(function (Get $get, Set $set, $state, $record) {
if( is_null($get('alt_text_input'))) {
if($record) {
if($record->getMedia('bar-images')->first()){
$set('alt_text_input', $record->getMedia("bar-images")->first()->custom_properties['alt_text']);
}
}
}
})
->image(),
...
]);
}
3 replies
FFilament
Created by Merlijn01 on 3/25/2024 in #❓┊help
Dark background color
Hi, I'm trying to make my first filament panels application. I would like to set the background to something dark (black or dark gray, like the dark mode). I've tried to set the colors in the AdminPanelProvider, but I don't believe there is a "backgroundColor" attribute. I believe that the problem is that it should be dark in the main mode (light mode I guess). Are there any solutions for this ? Thanks in advance !
class AdminPanelProvider extends PanelProvider
{
public function panel(Panel $panel): Panel
{
return $panel
->default()
->id('admin')
->path('admin')
->login()
->colors([
'primary' => '#1662AD',
]);
}
}
class AdminPanelProvider extends PanelProvider
{
public function panel(Panel $panel): Panel
{
return $panel
->default()
->id('admin')
->path('admin')
->login()
->colors([
'primary' => '#1662AD',
]);
}
}
https://filamentphp.com/docs/3.x/panels/themes
5 replies