make repeater items when create pade load data from db

hi dev in this case i want create stock opname items automaticly load item from db and loop it in repeater how can i do that thx u
29 Replies
LeandroFerreira
LeandroFerreira12mo ago
share some code you are trying please
jepewsykes
jepewsykesOP12mo ago
i dont know how to auto create repeater field when create page loaded i saw u in github auto add repeater but it trigger afterstateupdated now i want auto create when page loaded
toeknee
toeknee12mo ago
->default([['name' => 'Name'],['name' => 'Name2']]) To pre-fill a create form (not edit) on the repeater field would repeat two rows filling name field.
jepewsykes
jepewsykesOP12mo ago
thx bro i already try that way but i stuck on loop from db i used foreach inside shema(function(){return []}) i dont how but it rendered only 1 row oh ya bro if i want know how to save row to in session
jepewsykes
jepewsykesOP12mo ago
No description
jepewsykes
jepewsykesOP12mo ago
No description
jepewsykes
jepewsykesOP12mo ago
when i clicked simpan draft its row saved into session and if i refresh the page its still there
toeknee
toeknee12mo ago
If it's just that data, you would need to put that into a unique named session on lciking the save. But ensure you clear that when saving the actually form. Ideally you should have a sve as draft global action which saves everything without validation though.
jepewsykes
jepewsykesOP12mo ago
yes i will create a unique session name thx u for that now how to get all value from that repeater field event empy field
jepewsykes
jepewsykesOP12mo ago
No description
jepewsykes
jepewsykesOP12mo ago
and got null value 😦
toeknee
toeknee12mo ago
$get('../items') ? Assuming the repeater is named items ?
jepewsykes
jepewsykesOP12mo ago
items its repeater it self
toeknee
toeknee12mo ago
You are not making sense Please provide code snippet as per #❓┊help
jepewsykes
jepewsykesOP12mo ago
ok forget it sorry bro but default([[]]) it not work in my case
jepewsykes
jepewsykesOP12mo ago
No description
jepewsykes
jepewsykesOP12mo ago
No description
jepewsykes
jepewsykesOP12mo ago
and try this
jepewsykes
jepewsykesOP12mo ago
No description
jepewsykes
jepewsykesOP12mo ago
and got thi
jepewsykes
jepewsykesOP12mo ago
No description
toeknee
toeknee12mo ago
You have not used default correctly, you are missing the enclosed [] it's an array of array'ed data. Schema should contain each field
jepewsykes
jepewsykesOP12mo ago
No description
LeandroFerreira
LeandroFerreira12mo ago
If it is a text input, it should have a string, not array..
TableRepeater::make('items')
->schema([
TextInput::make('test'),
])
->default([
['test' => 'value1'],
['test' => 'value2']
])
TableRepeater::make('items')
->schema([
TextInput::make('test'),
])
->default([
['test' => 'value1'],
['test' => 'value2']
])
jepewsykes
jepewsykesOP12mo ago
No description
LeandroFerreira
LeandroFerreira12mo ago
First, ensure that each input in your foreach loop has a distinct name, and avoid using 'barang' for all of them.
jepewsykes
jepewsykesOP12mo ago
No description
jepewsykes
jepewsykesOP12mo ago
No description
jepewsykes
jepewsykesOP12mo ago
thx u so much brother God bless you 👍
Want results from more Discord servers?
Add your server