beforeStateUpdated is not working on Tables\Columns\ToggleColumn
Trying to update the
$state
before update. Used following code:
Tables\Columns\ToggleColumn::make('email_verified_at')
->beforeStateUpdated(function ($record, $state) {
return $state?date('Y-m-d H:i:s'):NULL;
})
Am i missed anything?9 Replies
I think you can't use a toggle for datetime fields....
email_verified_at is a datetime field
issue is the
$stack
is not updating when updating the recordNot sure if you can
You need to set it as null, that is trying to set it as 0 and the field cannot take 0 for datetime. only null if nullable.
to be clear, the toggle only returns true (1) or false (0) and it updates the record. In this case I need to set
null
instead of false
, so I used beforeStateUpdated()
the method to set it before update.
Did I made any mistake on that? kindly advice.
fyki, the toggle looks fine but unable to updateYou need to change the return to date time or null, that's if you can. But I'm not sure you can since toggle return boolean
sorry if i talk like stupid 😦
it actually works on
datetime
fieldOhh nice you made it. I tried it yesterday it keep giving me warning about 1 and 0 things.
i think you need to update your filament