RichEditor content is ignored

I have a simple schema:
public static function configure(Schema $schema): Schema
{
return $schema
->components([
Hidden::make('editor_id')
->default(auth()->id()),

TextInput::make('title')
->label(__('Title'))
->required()
->maxLength(255),

DateTimePicker::make('published_at')
->label(__('Published at'))
->displayFormat('d.m.Y, H:i')
->native(false)
->seconds(false)
->nullable(),

RichEditor::make('body')
->label(__('Body'))
->columnSpan('full'),

Toggle::make('is_active')
->label(__('Active'))
->default(true),
]);
}
public static function configure(Schema $schema): Schema
{
return $schema
->components([
Hidden::make('editor_id')
->default(auth()->id()),

TextInput::make('title')
->label(__('Title'))
->required()
->maxLength(255),

DateTimePicker::make('published_at')
->label(__('Published at'))
->displayFormat('d.m.Y, H:i')
->native(false)
->seconds(false)
->nullable(),

RichEditor::make('body')
->label(__('Body'))
->columnSpan('full'),

Toggle::make('is_active')
->label(__('Active'))
->default(true),
]);
}
When I save this I got an QueryException because the rich editor field (body) is missing:
General error: 1364 Field 'body' doesn't have a default value (Connection: mysql, SQL: insert into `announcements` (`editor_id`, `title`, `published_at`, `is_active`, `updated_at`, `created_at`) values (1, zuguz, ?, 1, 2025-09-25 17:31:35, 2025-09-25 17:31:35))
General error: 1364 Field 'body' doesn't have a default value (Connection: mysql, SQL: insert into `announcements` (`editor_id`, `title`, `published_at`, `is_active`, `updated_at`, `created_at`) values (1, zuguz, ?, 1, 2025-09-25 17:31:35, 2025-09-25 17:31:35))
If I replace the RichEditor with a Textarea field without any other changes it workes.
Solution:
ok, wow. I solved it. The body column has to be nullable even the field is required - This is mentioned in the filament spatie media library documention but can easily be overlooked here: https://filamentphp.com/plugins/filament-spatie-media-library#using-media-library-for-rich-editor-file-attachments
Using SpatieMediaLibraryFileAttachmentProvider requires that the rich content attribute (content in this example) must be defined as nullable in database....
Filament
Spatie Media Library by Filament - Filament
Filament support for Spatie's Laravel Media Library package.
Jump to solution
2 Replies
larsbo
larsboOP2w ago
Oh, it has something to do with the media handling. The rich editor works if I remove
public function setUpRichContent(): void
{
$this->registerRichContent('body')
->fileAttachmentsDisk('public')
->fileAttachmentProvider(SpatieMediaLibraryFileAttachmentProvider::make()
->collection('announcements')
);
}
public function setUpRichContent(): void
{
$this->registerRichContent('body')
->fileAttachmentsDisk('public')
->fileAttachmentProvider(SpatieMediaLibraryFileAttachmentProvider::make()
->collection('announcements')
);
}
from the model. But I want to handle the media via Spatie Media Library
Solution
larsbo
larsbo2w ago
ok, wow. I solved it. The body column has to be nullable even the field is required - This is mentioned in the filament spatie media library documention but can easily be overlooked here: https://filamentphp.com/plugins/filament-spatie-media-library#using-media-library-for-rich-editor-file-attachments
Using SpatieMediaLibraryFileAttachmentProvider requires that the rich content attribute (content in this example) must be defined as nullable in database.
Filament
Spatie Media Library by Filament - Filament
Filament support for Spatie's Laravel Media Library package.

Did you find this page helpful?