Select [all options] of dropdown inside repeater

I have (not multiple) select inside a repeater i use the repeater when i want to select more than one option i need to be able to select all options either by add a new option to dropdown or any other way such as radio
Forms\Components\Repeater::make('featuresTest')
->itemLabel(fn (array $state): ?string => Feature::query()->where('id',$state['feature_id'])->first()['name']?? null)
->relationship()
->schema([
Forms\Components\Select::make('feature_id')
->label('Feature')

->options(function(callable $get){
$test_type = $get('../../type');
if(!$test_type){
return ['Please, Enter the type first'];
}
return Feature::where('type',$test_type)->pluck('name','id');
})
->required()
->reactive()

->columnSpan([
'md' => 7,
])
Forms\Components\Repeater::make('featuresTest')
->itemLabel(fn (array $state): ?string => Feature::query()->where('id',$state['feature_id'])->first()['name']?? null)
->relationship()
->schema([
Forms\Components\Select::make('feature_id')
->label('Feature')

->options(function(callable $get){
$test_type = $get('../../type');
if(!$test_type){
return ['Please, Enter the type first'];
}
return Feature::where('type',$test_type)->pluck('name','id');
})
->required()
->reactive()

->columnSpan([
'md' => 7,
])
10 Replies
BlackShadow
BlackShadow16mo ago
What is the goal of this approach exactly? Compared to:
Select::make('technologies')
->multiple()
Select::make('technologies')
->multiple()
Thigah Alattass
Thigah AlattassOP16mo ago
featuresTest is a pivot model I add a repeater because there are other data in the pivot table i need them in (edit and view pages) so i have several fields other than Select
BlackShadow
BlackShadow16mo ago
So what is the problem rn?
Thigah Alattass
Thigah AlattassOP16mo ago
sometimes the user needs to add all the features to the test so i need a way to add them without selecting them manually one by one I tried to add radio button to choose if i need all features and tried to adding them using code when the radio returns true but i couldn't perform that, it always gives me error (feature_id is null) when i submitted the form
BlackShadow
BlackShadow16mo ago
So your options needs to be filled with values if another field is true?
Forms\Components\Select::make('feature_id')
->label('Feature')
->options(), // All options here if test_type true
Forms\Components\Select::make('feature_id')
->label('Feature')
->options(), // All options here if test_type true
Thigah Alattass
Thigah AlattassOP16mo ago
option is already filled according to test_type (which is the value of another dropdown) but i need them all to be selected and sent when another value is true for example I have radio called (select all features) when it is true, the dropdown becomes disable and all options are sent as selected when the radio is false, the user can select the desired feature from the dropdown
BlackShadow
BlackShadow16mo ago
ooh
Thigah Alattass
Thigah AlattassOP16mo ago
or if there is any other way to select all options it will be great
Thigah Alattass
Thigah AlattassOP16mo ago
I tried to use that before, but i did not get the desired result because the repeater and select is for only one object so when i assign one feature_id, it works well but i need to assign all features I will try again Thank you
Want results from more Discord servers?
Add your server