Is it possible to add multiple items to a repeater?
With an action button for example.
32 Replies
You should be able to do that with a mountUsing() and populate it that way
could you please show how to do it i really need this
Can you explain your use case exactly on what type, as default or as edit etc
i just need to populate repeater based on select item for example i have products and warehouse if chose warehouse i want related products to be passed into my repeater may be with an action button if possible
So that's just stateupdated on the select item
the repeater is getting the data but i want to show the list here is my code
What do you mean show the list?
should be
assuming you have an ID and a Title within the products
based on your code there could be list of array with id and a title so just show that with in the repeater
Yes so you use the above, you pass in the array with sub arrays with id and title or id and name etc
i want to show the product name and quantity in place holder in the repeater after i have used the above code and changed ->pluck('id', 'title'); to ->pluck('product_name', 'quantity'); am getting this screenshot
this is my repeater
That won't work All I can see is you have a single product name. So actually you want to change that to be:
Run a DD on:
What does the above give you?
Ahn you are filling place holders, one second
try:
this is the dd
i get this if i try to write twice
i want each product and its quantity as one item in the repeater
Yeah because pluck is more for a select. So let's adjust it:
That should dd with:
[
'product_name' => 'Mobiles',
'quanity' => 500.000000
],
[
'product_name' => 'laptops',
'quanity' => 200.00000
]
yes i have that array that looks jjust like this but how can i show in the repeater
By using the above that should now pass into the repeater with the above code I adjusted?
If you want to use placeholders instead just use: $state['product_name']
what am i doing wrong its giving me this error "Attempt to read property "product_name" on array "
Sorry I\m doing too many things at once, you need to call the array part because you pass in an array not an object like normal for state.
should work with the above...
I am really grateful to your help so far to this stage and ihave been trying really hard but i could figure out on how? i tried to use loop to get each object and may be map function but neither solution did not work. So please find sometime for me to help this for one last time thank you in advance
this is what i get for using loop or map function to get each object
Ok so looking at that, you are repeating the product throughout the map... Can you provide what code you are using now
Can you provide whats about the schema? As you are returning the schema for the repeater has been repeated 3 times as if it's got 3 rows of data from somewhere?
here is the gist
Do you have a releationship on your LCLJobs Model for 'products' ?
yes i have
That's why then 😉 so the products are being loaded in the repeater way! the correct way so lets try this:
That should then load the product_name of each item returned from the relationship
ohh thank you so much i do not know how i should appreciate this its been weeks since i have been trying hard thank you once again
Absolutely no problem