F
Filamentā€¢9mo 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
Maseaā€¢9mo 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ā€¢9mo ago
Try: ../cargo_tracking_code But I think you need to get it's parent instead
Masea
Maseaā€¢9mo 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ā€¢9mo ago
Sorry, then that should work... maybe change Get $get to callable $get
Masea
Maseaā€¢9mo ago
That also doenst work šŸ˜¦ Bump!
Vp
Vpā€¢9mo 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ā€¢9mo 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ā€¢9mo ago
And the main problem I think is you don't have Teslim edildi value inside your OrderStatus::class enum
Masea
Maseaā€¢9mo 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
More Posts