Group of items inside a group
Hello, is it possible to make a group of items inside another group? as the image shows for example
4 Replies
You can nest any form components as deep as you want.
But it needs to make sense with the data.
thanks for the reply 😄
Now I need to insert an item from a repeater, from the outside I can add it fine, but from inside the repeater I don't know how to do it, any ideas?
this is my code example:
Select::make('kit_id')
->live()
->options(function () {
return Kit::all()->pluck('code', 'id');
})
->afterStateUpdated(
function ($set) {
$actionEJ = [
['category_id' => 2,'article_id' => 3,'article_quantity' => 12],
['category_id' => 3,'article_id' => 5,'article_quantity' => 22],
];
$set('test', $actionEJ ?? null);
}
),
Forms\Components\Repeater::make('test')
->schema([
Forms\Components\TextInput::make('category_id'),
Forms\Components\TextInput::make('article_id'),
Forms\Components\TextInput::make('article_quantity'),
]),
Select::make('kit_id')
->live()
->options(function () {
return Kit::all()->pluck('code', 'id');
})
->afterStateUpdated(
function ($set) {
$actionEJ = [
['category_id' => 2,'article_id' => 3,'article_quantity' => 12],
['category_id' => 3,'article_id' => 5,'article_quantity' => 22],
];
$set('test', $actionEJ ?? null);
}
),
Forms\Components\Repeater::make('test')
->schema([
Forms\Components\TextInput::make('category_id'),
Forms\Components\TextInput::make('article_id'),
Forms\Components\TextInput::make('article_quantity'),
]),
but if move the select inside the repeater here is the problem
Obviously this doesn't do anything, any ideas?
⬆️
Forms\Components\Repeater::make('test')
->schema([
Select::make('kit_id')
->live()
->options(function () {
return Kit::all()->pluck('code', 'id');
})
->afterStateUpdated(
function ($set) {
$actionEJ = [
['category_id' => 2,'article_id' => 3,'article_quantity' => 12],
['category_id' => 3,'article_id' => 5,'article_quantity' => 22],
];
$set('test', $actionEJ ?? null);
}
),
Forms\Components\TextInput::make('category_id'),
Forms\Components\TextInput::make('article_id'),
Forms\Components\TextInput::make('article_quantity'),
]),
Forms\Components\Repeater::make('test')
->schema([
Select::make('kit_id')
->live()
->options(function () {
return Kit::all()->pluck('code', 'id');
})
->afterStateUpdated(
function ($set) {
$actionEJ = [
['category_id' => 2,'article_id' => 3,'article_quantity' => 12],
['category_id' => 3,'article_id' => 5,'article_quantity' => 22],
];
$set('test', $actionEJ ?? null);
}
),
Forms\Components\TextInput::make('category_id'),
Forms\Components\TextInput::make('article_id'),
Forms\Components\TextInput::make('article_quantity'),
]),