Closed crynobone closed 2 years ago
@kusab85 I don't understand why you code it as below:
Text::make('Title')
->rules('required')
->dependsOn(['user'],
function (Text $field, NovaRequest $request, FormData $formData) {
logger(get_class($this).": User changed to ".var_export($formData->user, true));
}
)
->dependsOn(['status'],
function (Text $field, NovaRequest $request, FormData $formData) {
logger(get_class($this).": Status changed to ".var_export($formData->status, true));
}
)
->dependsOn(['created_at'],
function (Text $field, NovaRequest $request, FormData $formData) {
logger(get_class($this).": Created at changed to ".var_export($formData->created_at, true));
}
),
If Title
depends on user
, status
and created_at
it should be ->dependsOn(['user', 'status', 'created_at'], ...)
Text::make('Title')
->rules('required')
->dependsOn(['user', 'status', 'created_at'],
function (Text $field, NovaRequest $request, FormData $formData) {
ray(get_class($this).": User changed to ".var_export($formData->user, true));
ray(get_class($this).": Status changed to ".var_export($formData->status, true));
ray(get_class($this).": Created at changed to ".var_export($formData->created_at, true));
}
),
Open Posts page and edit a Post. Callback function is called only once when page is being loaded. After that, changing value of the User field does not do a thing. Just look into laravel.log
Cheers!
UPDATE: It seems that dependsOn doesn't work at all, no matter what field uses it. Check 'Post With Dependencies' page in my TestApp
Originally posted by @kusab85 in https://github.com/laravel/nova-issues/issues/4751#issuecomment-1234355775