Build repeater schema from action

How can I build / add / create a repeater schema when the user clicks an action?
Actions::make([
Action::make('generate_variations')
->label('Generate Variations')
->action(function (Get $get, Set $set, $action) {
$this->variationsSchema = $this->generateVariations();
// add the generated code to the repeater field
}),
])->columnSpanFull(),
Repeater::make('variations')
->columnSpanFull()
->collapsible()
->schema([]
Actions::make([
Action::make('generate_variations')
->label('Generate Variations')
->action(function (Get $get, Set $set, $action) {
$this->variationsSchema = $this->generateVariations();
// add the generated code to the repeater field
}),
])->columnSpanFull(),
Repeater::make('variations')
->columnSpanFull()
->collapsible()
->schema([]
Trying to replicate WooCoomerce Generate Variations functionality. The user clicks on Generate Variations button and I need to add all variations to my Repeater
No description
1 Reply
Will πŸ‡¬πŸ‡Ή
Will πŸ‡¬πŸ‡ΉOPβ€’17h ago
I got working. I was looking at this incorrectly 😒 schema is the "input structure" I just needed to pass the array on how this inputs were going to work with
>action(function (Get $get, Set $set, $action) {
$set('variations', [
'testing-1' => [
'name' => 'Testing 1',
'alias' => 'Awesome alias',
'sku' => 'SKU-1',
'regular_price' => 100,
],
'testing-2' => [
'name' => 'Testing 2',
'alias' => 'Awesome alias 2',
'sku' => 'SKU-1',
'regular_price' => 200,
],
'testing-3' => [
'name' => 'Testing 3',
'alias' => 'Awesome alias 3',
'sku' => 'SKU-1',
'regular_price' => 300,
],
]);
})
>action(function (Get $get, Set $set, $action) {
$set('variations', [
'testing-1' => [
'name' => 'Testing 1',
'alias' => 'Awesome alias',
'sku' => 'SKU-1',
'regular_price' => 100,
],
'testing-2' => [
'name' => 'Testing 2',
'alias' => 'Awesome alias 2',
'sku' => 'SKU-1',
'regular_price' => 200,
],
'testing-3' => [
'name' => 'Testing 3',
'alias' => 'Awesome alias 3',
'sku' => 'SKU-1',
'regular_price' => 300,
],
]);
})

Did you find this page helpful?