F
Filamentā€¢13mo ago
Masea

$get doesn't work in action modal

Inside my infolist schema, I have an textentry with a hint action. the form loads perfectly well, but a dependant field (cargo_tracking_code) cannot get the status field's value. The code is attached.
9 Replies
Masea
MaseaOPā€¢13mo ago
TextEntry::make('status')
->hintAction(
Action::make('updateStatus')


->form(function (Order $record) {
return [
Select::make('status')
->required()
->hiddenLabel()
->selectablePlaceholder(false)
->options(OrderStatus::class)
->live(),

TextInput::make('cargo_tracking_code')
->visible(function(Get $get, $state) {
$status = $get('status');

return $status === "Teslim edildi" || $status === "Kargolandı" || $state;
})
];
})
TextEntry::make('status')
->hintAction(
Action::make('updateStatus')


->form(function (Order $record) {
return [
Select::make('status')
->required()
->hiddenLabel()
->selectablePlaceholder(false)
->options(OrderStatus::class)
->live(),

TextInput::make('cargo_tracking_code')
->visible(function(Get $get, $state) {
$status = $get('status');

return $status === "Teslim edildi" || $status === "Kargolandı" || $state;
})
];
})
toeknee
toekneeā€¢13mo ago
Try: ../cargo_tracking_code But I think you need to get it's parent instead
Masea
MaseaOPā€¢13mo ago
Where exactly should I try it tho? I am trying to get status field's value by using $get('status'), not the other way around
toeknee
toekneeā€¢13mo ago
Sorry, then that should work... maybe change Get $get to callable $get
Masea
MaseaOPā€¢13mo ago
That also doenst work šŸ˜¦ Bump!
Vp
Vpā€¢13mo ago
visible expect boolean so you need to return like this
->visible(function(Get $get, $state) {
if ($get('status') == "Teslim edildi" || $get('status') == "Kargolandı" || $get('status') == $state) {
return true;
}

return false;
})
->visible(function(Get $get, $state) {
if ($get('status') == "Teslim edildi" || $get('status') == "Kargolandı" || $get('status') == $state) {
return true;
}

return false;
})
Augus
Augusā€¢13mo ago
->visible(function (Get $get, $state) {
return in_array($get('status'), [$state, 'Kargolandı', 'Teslim edildi']);
})
->visible(function (Get $get, $state) {
return in_array($get('status'), [$state, 'Kargolandı', 'Teslim edildi']);
})
But both should work fine normally.
Vp
Vpā€¢13mo ago
And the main problem I think is you don't have Teslim edildi value inside your OrderStatus::class enum
Masea
MaseaOPā€¢13mo ago
Thanks for the responses. The problem is that $get('status') returns null. So i cant even read the field in the first place
Want results from more Discord servers?
Add your server