laravel / nova-issues

554 stars 35 forks source link

Undefined variable $model #6501

Closed guoxiangke closed 1 week ago

guoxiangke commented 4 weeks ago

hi, I use

Text::make('Name', 'name') ->fillUsing(function ($request, $model, $attribute, $requestAttribute) { $model->{$attribute} = Str::title($request->input($attribute)); }),

but it said Undefined variable $model. Where can I get current $model? what if this is a create page? thanks.

crynobone commented 4 weeks ago

Unable to reproduce the issue, please provide full reproducing repository based on fresh installation as suggested in the bug report template (or you can refer to https://github.com/nova-issues for example)

guoxiangke commented 3 weeks ago

In the document(Field Hydration): https://nova.laravel.com/docs/resources/fields.html#field-hydration it's provide a $model in the fillUsing function. I just wonder what if create a new entity of a model, but the $model still not exist.

crynobone commented 3 weeks ago

Still need the reproducing repository as I have no idea why it isn't working on your usage, also we don't have any other report regarding this widely used feature.

crynobone commented 1 week ago

Hey there,

We're closing this issue because it's inactive, already solved, old, or not relevant anymore. Feel free to open up a new issue if you're still experiencing this problem.