Error when I use searchable() in wizard step
Hello everyone. I have an error when I want to use a Select with searchable() in a wizard step. Error: Cannot read properties of null (reading 'location'), my code:
Wizard\Step::make('form')
->icon('heroicon-o-pencil')
->label('Formulario')
->schema([
Forms\Components\TextInput::make('name')
->label('Nombre')
->required(),
Forms\Components\TextInput::make('last_name')
->label('Apellidos')
->required(),
Forms\Components\TextInput::make('dni')
->label('DNI')
->required(),
Forms\Components\Select::make('location')
->label('Población')
->required()
->options(CpMunicipality::get()->take(20)->pluck('name', 'id'))
->searchable()
->columnSpan(3),
Forms\Components\TextInput::make('contact_name')
->label('Nombre persona contacto')
->required(),
Forms\Components\TextInput::make('contact_last_name')
->label('Apellido persona contacto')
->required(),
Forms\Components\TextInput::make('email')
->label('Email')
->required(),
Forms\Components\TextInput::make('phone')
->label('Teléfono')
->required(),
]),
If I remove searchable(), the error goes away. Can anybody help me? I am doing something wrong? Thank you10 Replies
try:
That wojn't work either you need morelike:
and
Thank you but I keep getting the error. My code:
Forms\Components\Select::make('location')
->label('Población')
->required()
->options(fn() => CpMunicipality::get()->take(20)->pluck('name', 'id'))
->getSearchResultsUsing(fn (string $search) => CpMunicipality::where('name', 'like', "%{$search}%")->limit(50)->pluck('name', 'id'))
->searchable(),
How about that? Failing that I am unsure
No, stay the same 😭
I don't believe that searchable() is the issue
Can you share the whole code please?
Hi, I'm sorry for the delay. This is my whole code. I have cleaned up the code and I have left only a select without a wizard at the end, and the same error appears. I think it's because it's a Livewire component, it's the first time I've used it. Maybe i'm missing something ?
You have missed the mount functio off
Omgsh, thank you very much, now it works! The only thing, I don't have to fill in is the form, can I leave the fill empty?
Yep, that's what [] does. If you wanted values you put them in there.
Ok, thank you @toeknee_iom muito obrigada @leandro_ferreira