You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the filling logic of a field depends on another field we can use the fillUsing method of an attribute to customize the filling logic. In doing so the order of the field definitions matters as the hydrator goes in order and hydrates each field.
Laravel Nova gets the entire request when it hydrates a field:
We could pass the entire validated request data in the fillUsing Closure too, so that we don't have to depend on the field definition order.
The text was updated successfully, but these errors were encountered:
X-Coder264
changed the title
Filling fields which depend on another field depend on the order of field definition in the schema
Filling fields which depend on another field depends on the order of field definition in the schema
Apr 7, 2021
Just to note what I said on Slack... we don't want to pass the whole request, because we will need to decouple from requests in the near future to support #39 Atomic Operations.
So the solution is probably invoking the fillUsing hydrator like this:
if ($this->hydrator) {
($this->hydrator)($model, $this->column(), $value, $validatedData);
return;
}
I've gone with passing the validated data as the fourth argument, as per my comment above. Would be good to get confirmation from you that it works well for your use case!
When the filling logic of a field depends on another field we can use the
fillUsing
method of an attribute to customize the filling logic. In doing so the order of the field definitions matters as the hydrator goes in order and hydrates each field.Laravel Nova gets the entire request when it hydrates a field:
We could pass the entire validated request data in the
fillUsing
Closure too, so that we don't have to depend on the field definition order.The text was updated successfully, but these errors were encountered: