Increase a select's option by the amount of reapeater in the form

I have this select in my form which is inside a repeater "Forms\Components\Wizard\Step::make('RulesCategoryDependent') ->label('Categories by Dependents') ->schema([ Forms\Components\Repeater::make('rules_category_dependents.dependent_category') ->label('Table') ->schema([ Forms\Components\Select::make('dependency_class') ->label('Select dependent class') ->options([ '1C' => '1st class', '2C' => '2nd class', '3C' => '3rd class', '4C' => '4th class' ]) ])" I need that when the number of 'repeater' is greater than four, another option is added to the selects. Example: if it has 5 it adds " '5C' => '5th class'", if it has 6 " '6C' => '6th class'". How to do this?
1 Reply
Marwam Malta
Marwam MaltaOP5mo ago
I managed to get here "->addAction(function($set, $get) { self::generateDependencyClassOptions($set, $get('rules_category_dependents.dependent_category')); })" "public static function generateDependencyClassOptions($set, $dependentCategories) { $dependencyClassOptions = [ '1C' => '1ª classe', '2C' => '2ª classe', '3C' => '3ª classe', '4C' => '4ª classe', ]; $repeaterCount = is_array($dependentCategories) ? count($dependentCategories) : 0; // dd($repeaterCount, $dependencyClassOptions); if ($repeaterCount > 4) { for ($i = 5; $i <= $repeaterCount; $i++) { $dependencyClassOptions["{$i}C"] = "{$i}ª classe"; } dd($dependencyClassOptions); } $set('dynamic_options', $dependencyClassOptions); }" even in "dd()" it mounts but I'm not able to set it in the selects
Want results from more Discord servers?
Add your server