watchout when afterStateUpdated from another component
i have this code
is_checked is checkBox component that is in a repeater so when using the above logic to make all true i want to trigger some logic but my afterStateUpdated function of is_cheked is not triggered how can i do this please Help me guys.
Forms\Components\Checkbox::make('Check All')
->columnSpan('full')
->live()
->reactive()
->afterStateUpdated(function (Forms\Get $get, Forms\Set $set, $state) {
$paymentDetails = $get('payment_details');
if ($state) {
if (is_array($paymentDetails)) {
foreach ($paymentDetails as &$detail) {
if (isset($detail['is_checked'])) {
$detail['is_checked'] = true; // Set the checked_value to true
}
}
}
}else {
if (is_array($paymentDetails)) {
foreach ($paymentDetails as &$detail) {
if (isset($detail['is_checked'])) {
$detail['is_checked'] = false; // Set the checked_value to true
}
}
}
}
$set('payment_details', $paymentDetails);
}),
Forms\Components\Checkbox::make('Check All')
->columnSpan('full')
->live()
->reactive()
->afterStateUpdated(function (Forms\Get $get, Forms\Set $set, $state) {
$paymentDetails = $get('payment_details');
if ($state) {
if (is_array($paymentDetails)) {
foreach ($paymentDetails as &$detail) {
if (isset($detail['is_checked'])) {
$detail['is_checked'] = true; // Set the checked_value to true
}
}
}
}else {
if (is_array($paymentDetails)) {
foreach ($paymentDetails as &$detail) {
if (isset($detail['is_checked'])) {
$detail['is_checked'] = false; // Set the checked_value to true
}
}
}
}
$set('payment_details', $paymentDetails);
}),
0 Replies