Repeater::make('questions')
->itemLabel(function () {
static $position = 1;
return 'Question n°'.$position++;
})
->schema([
textInput::make('title')
->required(),
Select::make('need_id')
->options(Need::all()->pluck('name', 'id'))
->required(),
Repeater::make('answers')
->itemLabel(function ($component, array $state, callable $get) {
$answers = $get('answers');
$answerKeys = array_keys($answers);
/*And now, I don't know what to do. How to get the current index of actual answer but without uuid ?*/
return 'Réponse n°';
})
->hiddenLabel()
->schema([
TextInput::make('title')
->required(),
TextInput::make('ratio')
->numeric()
->suffix('%')
->default('20')
->required()
])
->minItems(5)
->maxItems(5)
->addActionLabel('Ajouter une réponse')
->required()
])
->minItems(2)
->maxItems(4)
->addActionLabel('Ajouter une question')
->collapsible()
Repeater::make('questions')
->itemLabel(function () {
static $position = 1;
return 'Question n°'.$position++;
})
->schema([
textInput::make('title')
->required(),
Select::make('need_id')
->options(Need::all()->pluck('name', 'id'))
->required(),
Repeater::make('answers')
->itemLabel(function ($component, array $state, callable $get) {
$answers = $get('answers');
$answerKeys = array_keys($answers);
/*And now, I don't know what to do. How to get the current index of actual answer but without uuid ?*/
return 'Réponse n°';
})
->hiddenLabel()
->schema([
TextInput::make('title')
->required(),
TextInput::make('ratio')
->numeric()
->suffix('%')
->default('20')
->required()
])
->minItems(5)
->maxItems(5)
->addActionLabel('Ajouter une réponse')
->required()
])
->minItems(2)
->maxItems(4)
->addActionLabel('Ajouter une question')
->collapsible()