Argument #2 ($label) must be of type string, array given
Hi
While using the form builder I have 2 json repeater on the same form.
One repeater can add and delete entries
I fill the form with data, everything looks ok, but if I try delete or add I get this error:
is it not allowed to have 2 repeater on the same form ?
20 Replies
It is certainly possible to have multiple repeaters on the same form (even nested repeaters). Could you share the relevant code snippet?
my guess is that you have a Select with the same name as a Repeater?
hmmm
the problem is because you are putting the repeater directly as select options
it should be value=>label, not repeaterkey=>repeaterdata
Sorry... I don't understand
check the content of
$this->placeholderGroups
and compare it to what you would expect select options() to look like
they should be string values, not arrays$this->placeholderGroups is a different array of data
I have renamed it to placeholderGroupsOptions, but still the same
what is inside placeholderGroupsOptions
the end result should be that if a 'group' is added in the first repeater, then it should be available as a option in the select in the second repeater, but that is step 2 😀
now the placeholderGroupsOptions looks like this:
so now I don't get the error, but no values is added to the selelct in the second repeater until I add a new entry in the first repeater
but its up to you to populate placeholderGroupsOptions with the repeater items, right?
yes
but if it can be done 'automaticlly' that would be cool
the values in the second select should be the 'name'/'prompt' from the group repeater
->options(fn ($get) => collect($get('placeholderGroups'))->pluck('name', 'id'))
you could use $this->placeholderGroups
, but $get
is reccomendedthat would be awesome... I'll try
hmm.. I must be typing something wrong as it does not work.
both repeaters are working, but the select in the second repeater does not get the data from the first repeater
try
$get('../../placeholderGroups')
inside the second repeatersorry no
changed to this:
>options(function ($get) {
//debug($get);
$c = collect($get('../../placeholderGroups'))->pluck('name', 'prompt');
debug($c);
return $c;
}),
and $c contains 3 collections with no items
i dont see your placeholderGroups repeater
I just found it...
one second
works perfectly
Thanks!
small issue...
when adding a new group, the new 'entry' will have 'null' in either 'name' or 'prompt' until someting is entered.
As long as it's 'null' it will throw an error
I can simply iterate over the array and remove 'null' but is there a smart way?
->options(fn ($get) => collect($get('../../placeholder_groups'))->pluck('name', 'prompt')->filter()->all()),
Sounds like a smart way to me