Boolean not saving with underscore in field name.

I'm working with a legacy database that has some tinytext/boolean fields that begin with "_field_name". [leading underscore] I have set casting on model to boolean yet they do not save/update. I cannot change the field names.
Toggle::make('_hide')->label('Hide'), //does not work
Toggle::make('_hide')->label('Hide'), //does not work
Toggle::make('test_hide')->label('Hide'), //works fine
Toggle::make('test_hide')->label('Hide'), //works fine
I think somewhere the underscore is being stripped off. Any ideas how to fix this?
4 Replies
Dan Harrin
Dan Harrin2y ago
if it was stripped you would have an error bc missing database column are you sure its $fillable or something?
bionary
bionaryOP2y ago
I just spit out from mutateFormDataBeforeSave and can see it's working at that point...so i went next level and dd() inside Laravels updating lifecycle... that's where it is not right. I think its a Laravel naming convention thing looks like it's Laravel, not filament. 🤔 inside filament mutateFormDataBeforeSave I get $data['_hide'] == true but inside model updating I get $model->_hide = 0;
bionary
bionaryOP2y ago
yeah, just figured it out I had
protected $guarded=[];
protected $guarded=[];
but I needed to explicitly set them:
protected $fillable=[
'_hide',
];
protected $fillable=[
'_hide',
];
sigh, thanks Dan
Want results from more Discord servers?
Add your server