Answers::make('options')->addAction(
fn(Forms\Components\Actions\Action $action, $livewire) =
> $action->link()
->label('Add an Answer')
->icon('heroicon-o-plus')
->action(function(Forms\Set $set, array $state) {
$uuid = Str::uuid()->toString();
// Get Parent/ ownerRecord
$parentId = $livewire->ownerRecord->id;
$state[] = [
'uuid' = > $uuid,
'label' = > '',
'is_correct' = > false,
'disabled' = > true, // disable newly added item to options
'ordinal' = > count($state) + 1,
];
$set('options', $state);
}))
Answers::make('options')->addAction(
fn(Forms\Components\Actions\Action $action, $livewire) =
> $action->link()
->label('Add an Answer')
->icon('heroicon-o-plus')
->action(function(Forms\Set $set, array $state) {
$uuid = Str::uuid()->toString();
// Get Parent/ ownerRecord
$parentId = $livewire->ownerRecord->id;
$state[] = [
'uuid' = > $uuid,
'label' = > '',
'is_correct' = > false,
'disabled' = > true, // disable newly added item to options
'ordinal' = > count($state) + 1,
];
$set('options', $state);
}))