How to add an row to a repeater programmatically?

Hello! I am creating a HasMany relationships in my DB. Fields are displayed dynamically. Can I make it so that each new field is a new repeater line? It's as if the user clicked the "Add" button. I need each field value_string, value_integer to be a new attribute connection record. Perhaps I should use a different component? Thank you!
No description
No description
No description
5 Replies
toeknee
toeknee5mo ago
$set('attributes', [['value_string' => 'my 3 number', 'value_integer' => '333']]);
$set('attributes', [['value_string' => 'my 3 number', 'value_integer' => '333']]);
Citizer
CitizerOP5mo ago
I don't want to change the values. I want to add rows so that each of my fields is a new repeater row. If there are 5 repetitions in my loop, I want to have 5 records in attributes. Now after going through the cycle we get the following diagram: Repeater => ['rule_attribute_id', 'value_integer', 'value_integer', 'value_string'] I would like to get: Repeater => [['rule_attribute_id', 'value_integer'], ['rule_attribute_id', 'value_integer'], ['rule_attribute_id', 'value_stirng']]
toeknee
toeknee5mo ago
So get the values and merge them?
$set('attributes', array_merge(
$get('attributes', []),
[['value_string' => 'my 3 number', 'value_integer' => '333']]
));
$set('attributes', array_merge(
$get('attributes', []),
[['value_string' => 'my 3 number', 'value_integer' => '333']]
));
Citizer
CitizerOP5mo ago
I would like to get this behavior - each field is a new record in the table attributes and new row in repeater
No description
Citizer
CitizerOP5mo ago
And what I get is this: all fields are part of one record DB and one row in repeater
No description
Want results from more Discord servers?
Add your server