-
-
Notifications
You must be signed in to change notification settings - Fork 27
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
Translate File Field #18
Comments
Same issue here, I'm getting an error |
Hey everyone, Any updates ? |
same error, looking for solution! |
As a workaround, just add:
so your fields function will look like:
This needs to be done for each language you want to support (yeah... ugly). |
when trying @tonci method I get: Trix images work fine without the wrapper. |
@jrmadsen67 You have to use |
Is there any update here? Both Trix and Froala fields don't work with spatie/nova-translatable when it comes to file uploads/attachments. |
Do not forget to place it in the main array within the fields method of het Resource. It acts like a hidden field. Just to be sure. Thanks! |
Keep in mind that this workaround seems to be working only with Trix field type. If you are using a different type of editor (eg Froala), this is not enough to make it work, unfortunately. |
Had the same problem with file uploads using the // User Resource
public function fields(Request $request)
{
return [
//...
Translatable::make([
Trix::make('About')
->withFiles('public')
->alwaysShow(),
])
];
}
// Translatable field
namespace App\Nova\Fields;
use Laravel\Nova\Fields\Trix;
use Laravel\Nova\Fields\Field;
use Spatie\NovaTranslatable\Translatable as BaseTranslatable;
class Translatable extends BaseTranslatable
{
protected function createTranslatableFields()
{
parent::createTranslatableFields();
if ($this->onIndexPage()) {
return;
}
collect($this->locales)
->crossJoin($this->originalFields)
->eachSpread(function (string $locale, Field $field) {
if ($field instanceof Trix && $field->withFiles) {
$this->data[] = get_class($field)::make('translations_' . $field->attribute . '_' . $locale)
->onlyOnIndex()
->showOnIndex(false)
->withFiles($field->disk, $field->storagePath);
}
});
}
} @freekmurze I don't feel that this solution is clean in any way, but maybe it sparks an idea on your side on how to solve this in a more elegant way? Otherwise I am also open to create a PR with my fix if you want. |
What about File fields ? |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
When I try to translate a Nova File Field I get error when saving. The File Field is trying to save the
translations_FIELDNAME_LANG
attribute and not theFIELDNAME
attribute.I don't really see through how
nova-translatable
and the File Field are working so I have no idea what the best approach would be to fix this. If you have a hint I'd be happy to do a PR.The text was updated successfully, but these errors were encountered: