InfoList components on create - Schema has no [record()] or [state()] set.
On my create/edit forms I have a section to display data rather than input it, a sort of heading (see image). I used a mix of layout and infolist since now in v4 we can mix and match?
Code is below but I am getting 'Schema has no [record()] or [state()] set.' on create, edit works ok. Should the components return null if there is no state or should I be tackling this in different way? i.e. maybe a custom component.
// Header
Section::make()
->schema([
Flex::make([
Flex::make([
ImageEntry::make('avatar')
->hiddenLabel()
->circular()
->imageHeight(60)
->disk('public')
->grow(false),
Grid::make([])
->schema([
TextEntry::make('name')
->hiddenLabel()
->size(TextSize::Large)
->weight(FontWeight::SemiBold),
Text::make('Company')
])
->grow(false)
->gap(false)
]),
Flex::make([]),
Flex::make([
TextEntry::make('contact_name')
->label('Contact')
->size(TextSize::ExtraSmall),
TextEntry::make('contact_phone')
->label('Phone')
->size(TextSize::ExtraSmall),
TextEntry::make('created_at')
->label('Created')
->dateTime()
->size(TextSize::ExtraSmall),
TextEntry::make('updated_at')
->label('Updated')
->dateTime()
->size(TextSize::ExtraSmall),
])
]),
])
->columnSpanFull(),

12 Replies
where is the data coming from if you add an entry to the create form?
you need to pass a
->state()
method to the entry itself, at minimum, otherwise it has no state
a create form is a blank slate, there is no loaded data@Dan Harrin there is no data which is what I thought the components will check and render null by default but adding ->state(fn($record) => $record?->name ?? '---') on each component as you say fixes my issue. thanks for that.
we throw the exception as what is the point of a component that never renders anything apart from blank space
one that is used on both the create/edit forms is an example of my expectation.
if you did hiddenOn(‘create’) I bet it wouldnt throw the exception
and it isn't really blank space, the layout of the component, i.e. label, etc is just as important.
but I want it to render as blank for the content but keep it's layout, label, css, etc. just with null or dummy content if null. The ->state does that for me for sure.
Same form for Edit and Create that looks the same. It might be a better idea to use a custom component for this, i'm not sure.


if you pass ->default() to it, is the error the same?
unfortunately yes if I have the syntax correct
TextEntry::make('name')
->hiddenLabel()
->size(TextSize::Large)
->weight(FontWeight::SemiBold)
->default('---'),
ok that is a bug imo
you should report it
okie doke, haven't raised a bug before but I will have a go.
GitHub
->default() on TextEntry (possibly other components) on create form...
Package filament/filament Package Version v4.0.0pa l Laravel Version v12 Livewire Version v3 PHP Version 8.4.11 Problem description If you use ->default() on a Text Entry (maybe other components...