which works perfectly. So I know base_position_id is getting set correctly and should be available.
But a little farther down I have another select field that I'd like to filter based on base_position_id.
Grid::make() ->relationship('alt_manager_code') ->columns(1) ->schema([ Select::make('managerCode') ->label('Override Hiring Manager') ->placeholder('Select Position to Override Manager') ->options(function (Get $get) { info($get('base_position_id')); // LOG TO SEE IF VALUE IS AVAILABLE return BasePosition::all() ->sortBy('jobTitle') ->pluck('jobTitle', 'id'); }), ]),
Grid::make() ->relationship('alt_manager_code') ->columns(1) ->schema([ Select::make('managerCode') ->label('Override Hiring Manager') ->placeholder('Select Position to Override Manager') ->options(function (Get $get) { info($get('base_position_id')); // LOG TO SEE IF VALUE IS AVAILABLE return BasePosition::all() ->sortBy('jobTitle') ->pluck('jobTitle', 'id'); }), ]),
Obviously on first load, the logged value is empty. But when I select a base_position_id and the field refreshes, it still logs a blank value. Shouldn't I be getting the selected value at that point? I need it to add a filter to the return collection.
Solution
sorry, i miss-read where the relationship was. try
$get('../base_position_id')
$get('../base_position_id')
since you are in a layout component you need to traverse out of it to get the state from other fields.