Repeater relationship returns null
So, I have an issue where my relationship can't be found by repeater in my custom page, I want it to display every 'pergunta' inside the table formulario but I can't find the solution , this is the error returned:
Call to a member function cargoFormulario() on null
here's the code:
now the forms:
my model:
Only to give you guys more context about what I'm doing, a 'cargo' has many 'formulario' and a 'formulario' has many 'cargo'.
45 Replies
The custom page doesn't have a resource and I created that model ('Pergunta') after creating this page, its basically the name of the page
I have models for 'Formulario', 'Cargo' and 'CargoFormulario' , if needed I can post it here
You need to pass your record to the form
$form->record($yourRecord)
couldn't solve it, it returns this error 'Undefined variable $record'
I've created a new custom page on a resource
my code is able to pass the id in the url, but I can't get any data on form, this is how I did:
That is because it is a create repeater record doesn't exist, I think you want the parent record so $livewire then $livewire->owner_record
I'll try it
I did some progress and could get $record filled with the selected array that I wanted, now I just need to fill the forms with it
i've tried to use this in many ways but couldn't do it
here's my current code:
the 'dd($record)' in function mount returns the correct array, just need to find a way to send the description to the TextInput label inside the Repeater
I want to make a quiz by the way
I am not seeing a text input in the repeater? But if you added one... you would just do: $set('my_text_input', 'value')
![No description](https://cdn.answeroverflow.com/1265290904944775332/image.png)
I'm getting this error: Argument #1 ($record) must be of type App\Models\Cargo, null given
You will if record is null.... you specificed you expect Cargo so remove Cargo from it and then you can check if it's null
ok, did it and there was no error, but $record returned null in dd($record)
It will return null because no record exists?
yes, but I'm able to get the $record in function mount, I don't know how to send it to form
here, the dd returns the correct $record
public $record;
in mount:
$this->record = $record;
I think I did not explain it really well, I'm already receiving $record in mount, but I am not receiving it in my form
You are receiving it, but you are not setting it for your form to use it. I have told you above how to set it...