Repeater action -> modal

Hey all Feel like I live in this thread at the moment so I do apologise. I have the following: 1) Estimate Edit Page with a repeater showing EstimatePrices. It shows a slimed version. 2) I want an action on the repeater item to open up the estimatePrices record so I can perform further relationship components and show more fields. I cannot for the live of me figure out how to pass the repeater record model/collection in. To clarify I want the record of the repeater passed in and not the main parent record. Any help would be appreciated. Thank you.
18 Replies
David | Fortune Validator
thank yo. I was reading this. How would I pass it all through to a form on the modal though? I would have form componetns and another repeater ( relationship ) based off the data passed through sorry if I'm missing it Forgot to mention. I am using your TableRepeater if it makes any difference when I use the likes of `$itemData = $component->getItemState($arguments['item']); it passes the array through but I cannot run relationships off of it or more data than is in teh parent repeater
awcodes
awcodes2mo ago
You might have to make another db query at that point to be able to act on it. Table repeater still uses the native repeater class, it just uses a different view so all the functionality should still be the same.
David | Fortune Validator
do you know how one would pass a collection into the form though?I can obviously pass through an array of data but its the fact I need a collection / record to be passed through so I can run a repeater with a relationship off of it. thanks again I essentially need an EditRecord action but on a repeater instead of a table
awcodes
awcodes2mo ago
Hum. On my phone right now, so not going to be able to type a lot out. I would say to have a look at the CloneAction on the Repeater class itself. That might give you some more insight about how to access items themselves. Or the DeleteAction.
David | Fortune Validator
Good idea I'll take a look
awcodes
awcodes2mo ago
Basically though. ‘Item’ in this context is going to be the uuid key of the item in the repeaters state so that can be used to get the data back out of the component state. Which will be an array of that repeater items state. So you could either collect that, or use its id or some other attribute to re-query the db to get it’s model instance with its relationships. I could be misunderstanding the full use case too though.
David | Fortune Validator
I'll give it all another shot in the morning I think. Tired eyes and brain. thanks again not as ideal but I think I can work with this now:
->fillForm(function (array $arguments,Repeater $component) {
return EstimatePrice::with('estimateCosts')->find($component->getItemState($arguments['item'])['id'])->toArray();
})
->fillForm(function (array $arguments,Repeater $component) {
return EstimatePrice::with('estimateCosts')->find($component->getItemState($arguments['item'])['id'])->toArray();
})
This pulls in the estimate_costs relationship info I can then send to the repeater on the internal modal I’ll just need to manually sort out saving the record and its relationships which isn’t the end of the world
awcodes
awcodes2mo ago
Thought you were going to bed. Lol. Start with making it work first. Then worry about ideal.
David | Fortune Validator
I struggle going to bed when I have something unsolved. That’s good enough for me to go to sleep now haha. Only downside I can see is I am relying on a hidden field on the repeater to have the ID I need to then run the DB query filling the modal. I assume this may be able to be tampered with perhaps. Anyways it’s a step closer so thank you again.
And thanks for all the work you, been following you on twitter etc 👌🏻
awcodes
awcodes2mo ago
Ok. I’m definitely misunderstanding then. There shouldn’t be any hidden field. But get some rest. Have a good one. Thanks for following. I appreciate it.
David | Fortune Validator
Used the ID as a hidden field on the repeater so I could get the id of the db record. And then repopulate it on the action model
awcodes
awcodes2mo ago
Can talk more after you’ve had some rest and I’m at a computer with an actual keyboard. 😂 Yea. This shouldn’t be needed. It’s all available on the component.
David | Fortune Validator
Maybe I’m missing it somewhere in there then. I did try to locate it. In short I simply need to mimic the EditAction on a table row but on a repeater ‘row’ instead. I was just struggling to find a way to grab said record and populate the form model when clicking the action If it’s available in the component though I’ll have to take another look. I managed to get the array of data that exists visibly on the repeater but that’s not the db record itself of which I could then run further relationship components etc. Anyway must go to sleep. Off on holiday with the family in the morning 🍻 thanks again
awcodes
awcodes2mo ago
Yea. Feel free to hit me up tomorrow. And we can work through it. Or when you’re back from holiday.
Want results from more Discord servers?
Add your server