Problem showing array in Infolist using RepeatableEntry
I have Product table with 'syn' field which takes multiple entries. I am using repeater for this in form. Now, I am using View file where I want to see all my 'syn'. I am using below code in Infolist.
RepeatableEntry::make('syn')->schema([
TextEntry::make('syn') )]. But it gives me list of empty entries. So if I have 11 entries, then it gives 11 empty blocks. I tried using RepeatableEntry::make('$this->product->syn') or RepeatableEntry::make('$this->product') both gave error. RepeatableEntry::make('syn') does not give error and also lists exact blocks for entries. But why data not populated. Please help. In my migration syn is json type and in Product model I have already cast it array. Form or Table view is great.
Solution:Jump to solution
You can simple display simple repeater json data like this
```php
RepeatableEntry::make('syn') // syn is json column
->schema([
TextEntry::make('') // leave empty...
12 Replies
First off, you have to put the schema into a closure. There is a bug that leads to all entries being the first one. Secondly, if syn is an array, you should access to array entries in the TextEntries inside the repeater, no?
Also please read #❓┊help on how to ask for help, your code needs formatting to start.
Thanks @josef for the response. But I dint understand your second part. Thanks for pointing @toeknee . Here is my formatted code. ‘’’ RepeatableEntry::make('syn')
->schema([
TextEntry::make('syn'),
])->grid(2)’’’
it should be formatted as per:
What is syn? If syn is returning a relationship or an array of data, the TextEntry should be the sub part
thanks for pointing. I just joined yesterday. As mentioned 'syn' is a json field as it takes simple text entries using a repeater in a form. I have casted it to array in Product Model. It is not returning any relationship. 'syn' field stores all synonyms for a Product.
I just want to show list of all synonyms in a responsive two column. I have long list of 20-50 synonyms for a Product.
That's fine, but you have syn syn. Wouldn't it be more: syn (as the json field) then 'name' for the syn?
I am using Simple Repeater as one of the Repeater feature in Filament3 which can be used if entries are simple. Would you mind recommending best approach accepting and populating it in Infolist. I am just 1 month in Laravel and filament. I uses 'syn' 'syn' because that what i could understand to use RepeatableEntry for populating.
They should still be different names even with simple repeater. https://filamentphp.com/docs/3.x/forms/fields/repeater#simple-repeaters-with-one-field
This also probably shouldn’t be a json column since json requires a key and simple is looking for a non keyed array.
Even if I keep different names in Simple Repeater, my results are same. Now I changed TextEntry under Simple Repeater from 'syn' to 'synonym_name'. Interesting part is My Table view and Form views are fine. I can even store this array in a different variable and run foreach loop to show in whatever way I can. However, Its not working as expected in Infolist RepeatableEntry. I even changed my data type in migration file from JSON to longText.
Solution
You can simple display simple repeater json data like this
Thanks alot. It worked like a charm. Thanks alot @Vp .