-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compatibility issue with spatie/nova-translatable #40
Comments
@fede91it could you supply an example? |
@wize-wiz Not OP, but I ran into the same problem today. I'm trying to have a Textfield that's translatable and which depends on the value of a select. The code I'm trying to get to work is quite simple:
But it fails in Here's the code of the method that throws (NovaDependencyContainer.php on line 164):
The error message is:
Edit: Fixed missing code in my example |
@ThisIsJustARandomGuy Thanks for the input. Just out of curiosity, what does I'll look into it. |
I haven't tested it yet, but this should fix the problem.
public function __construct(array $fields = []) {
...
$this->createTranslatableFields();
} which calls $translatedField = clone $originalField;
$translatedField
->resolveUsing(function (...) {
...
});
return $translatedField; So the protected function resolveAttribute($resource, $attribute)
foreach ($this->meta['fields'] as $field) {
// patch for nova-translatable
// https://github.com/epartment/nova-dependency-container/issues/40
if(is_a($field, \Illuminate\Http\Resources\MergeValue::class)) {
foreach($field->data as $translated_field) {
$translated_field->resolveForDisplay($resource);
}
continue;
}
// changed to resolveForDisplay(), resolve() will be called when displayCallback is empty.
$field->resolveForDisplay($resource);
}
return [];
} |
@ThisIsJustARandomGuy sorry, I updated the comment a view times. Try the fix if you like and if it works, let me know, I'll pull it in the next release. |
@wize-wiz Sorry for the late reply. I missed some code in my original comment. It should say |
@wize-wiz I got it to work correctly by overriding the NovaDependencyContainer constructor with a slightly altered version of your patch:
|
That doesn't seem right even if it might fix the problem. The translatable container should manage resolving its own fields, I'll look into this problem when I have some more time to test around. |
Still... spatie/nova-translatable#34 |
I'm facing same issue. does anybody have a solution for this? |
It doesn't work with https://github.com/spatie/nova-translatable, could someone help me identify and solve the problem?
The text was updated successfully, but these errors were encountered: