F
Filamentβ€’15mo ago
Chriis

[object Object] shows as default in Repeater->simple(TextInput)

Hi, I have text into my input by default but I don't understand why ...
No description
14 Replies
Matthew
Matthewβ€’15mo ago
Can you share some code?
DrByte
DrByteβ€’15mo ago
I've seen that when I create a Form Select field with native(false) set and a complex options() query. Like, this works fine: native(false)->options(Model::all()->pluck('name', 'id'))
But if I'm doing something more complex like the following, I get the [object Object] output you mentioned:
->allowHtml()
->native(false)
->options(Model::all()->pluck('name_description', 'id'))
->allowHtml()
->native(false)
->options(Model::all()->pluck('name_description', 'id'))
(in this case the 'name_description' is actually a custom Attribute on my model, which concatenates the two fields with a <br> tag ... not super complex, but it's a custom Attribute, and not a direct model property) Hopefully that gives you an idea where to explore what your problem's root is. But like Matthew said, it's always easier to help if you provide the code that's causing it. πŸ™‚
Chriis
ChriisOPβ€’15mo ago
Well the code is really not that complex, its just a section into a Wizard step. I'm writing it in the CreateFoo page of my Foo resource. Tell me if you want to see a specific part, but honestly its just when I use the simple() method on my repeater ...
No description
No description
Chriis
ChriisOPβ€’15mo ago
This code is into getSteps(), from the HasWizard trait Its probably better than an image
Section::make('Objectives')
->collapsible()
->collapsed()
->schema([
Repeater::make('objectives')
->simple(
TextInput::make('test'),
)
]),
Section::make('Objectives')
->collapsible()
->collapsed()
->schema([
Repeater::make('objectives')
->simple(
TextInput::make('test'),
)
]),
DrByte
DrByteβ€’15mo ago
Ya, I get the same with a non-wizard form:
public function form(Form $form): Form
{
return $form
->schema([
Repeater::make('objectives')
->simple(
TextInput::make('test')
)
]);
}
public function form(Form $form): Form
{
return $form
->schema([
Repeater::make('objectives')
->simple(
TextInput::make('test')
)
]);
}
DrByte
DrByteβ€’15mo ago
No description
DrByte
DrByteβ€’15mo ago
I'm not sure if it's something that is cascading from the simple-repeater.blade.php template into the $item slot where text-input.blade.php is rendered, or if it's just something inside the text-input.blade.php file itself. Or might be elsewhere altogether. But it seems to only happen with ->simple(). Maybe should update the Title of this post to something like "[object Object] shows as default in Repeater->simple(TextInput)" ? Seems to only happen if there's no dataset. If you add a ->default(['foo']) array, it's fine.
Chriis
ChriisOPβ€’15mo ago
Yes, its better It doesnt work for me even with a default 😦
toeknee
toekneeβ€’15mo ago
Default only works on create not edit
Chriis
ChriisOPβ€’15mo ago
Its into a Wizard for resource creation, in a CreateRecord class
toeknee
toekneeβ€’15mo ago
Is your livewire and filementphp fully up to date? There was a big a few versions back for the object, object.
Chriis
ChriisOPβ€’15mo ago
Well yes, I think I've a composer update recently in order to fix this bug and also because I couldn't use simple() on my repeater (my version of filament was too old) ... But now, I don't know what else I can do to fix this problem
toeknee
toekneeβ€’15mo ago
try: ->options( fn() => Model::all()->pluck('name_description', 'id')) failing that try: ->options( fn() => Model::where('id' , '=>', 0)->pluck('name_description', 'id'))
Chriis
ChriisOPβ€’15mo ago
Options ? On my Repeater ?
Want results from more Discord servers?
Add your server