Dependent select input

I need feature_id dropdown to be populated depending on test_type value but $get('test_type') is giving me null ->schema([ Forms\Components\Group::make() ->schema([ Forms\Components\Card::make() ->schema([ Card::make()->schema([ TextInput::make('name')->required(), ]), Select::make('test_type') ->required() ->options([ 'auto-test' => 'Auto Test', 'stress-test' => 'Stress Test', ]) ->reactive(), //->afterStateUpdated(function(callable $set){$set('feature_id',null);
// }), Forms\Components\MarkdownEditor::make('notes') ->columnSpan('full'), Forms\Components\Select::make('status') ->default('pending') ->options([ 'pending' => 'Pending', 'processing' => 'Processing', 'completed' => 'Completed', 'failed' => 'Failed', 'has error' => 'Has Error', ]) ->hiddenOn('create'),]) ->columns(2),
6 Replies
Thigah Alattass
Thigah AlattassOP2y ago
The rest of the code Forms\Components\Section::make('Test features') ->schema( //static::getFormSchema('features') [ Forms\Components\Repeater::make('featuresTest') ->relationship() ->schema([ Forms\Components\Select::make('feature_id') ->label('Feature') ->options(function(callable $get){ $type = $get('test_type'); Log::debug($type); if(!$type){ return ['Please, Enter the type first']; } return Feature::where('type',$type); }) ->required() ->reactive() ->columnSpan([ 'md' => 7, ]),
Vp
Vp2y ago
Please format your code using three backtick which is written in #✅┊rules , and only show which is related to question..
toeknee
toeknee2y ago
Your code is a bit of a mess as it's not formatted or complete as VP says. You will likely need to traverse the structure. i.e. if it's in a group above you do: $get('../test_type')
Thigah Alattass
Thigah AlattassOP2y ago
Thank you it worked and I apologize for the mess
toeknee
toeknee2y ago
Please do this.
Want results from more Discord servers?
Add your server