Voyager: [BUG] Rich Text Box

Created on 9 Apr 2019  路  14Comments  路  Source: the-control-group/voyager

Version information

  • Laravel: v5.8.10
  • Voyager: v1.2.3
  • PHP: 7.2
  • Database: MariaDB 10.3

Description


After upgrade from version 1.2.2 to 1.2.3
Multilang at where using Rich Text Box have problem and unable to add or edit

Steps To Reproduce

Steps to reproduce the behavior:

  1. Laravel new voyager
  2. composer require tcg/voyager
  3. php artisan voyager:install --with-dummy
  4. config/voyager.php using DOC https://docs.laravelvoyager.com/core-concepts/multilanguage
  5. create new table with model and a field that named 'body'
  6. Add use Translatable; protected $translatable = ['body']; to model
  7. add bread (one field with Rich text box)
  8. add new row to table using bread

ErrorException (E_NOTICE)
Undefined index: en

$transFields = $this->getTranslatableAttributes();

        foreach ($transFields as $field) {
            if (!$request->input($field.'_i18n')) {
                throw new Exception('Invalid Translatable field'.$field);
            }

            $trans = json_decode($request->input($field.'_i18n'), true);

            // Set the default local value
            $request->merge([$field => $trans[config('voyager.multilingual.default', 'en')]]);

            $translations[$field] = $this->setAttributeTranslations(
                $field,
                $trans
            );

            // Remove field hidden input
            unset($request[$field.'_i18n']);
        }

        // Remove language selector input
        unset($request['i18n_selector']);

        return $translations;

possible bug

Most helpful comment

I managed to resolve the issue by changing 1 line at resources/assets/js/multilingual.js file. Upon changing you will need to run the command "npm run dev" to generate a new app.js file at voyager vendor folder itself.

I have created a pull request for this at #4077 so please do verify if it does fix your issues as well.

All 14 comments

Same here. New installation of 1.2.3 version still same error.

Same here, post data of _i18n-field is empty.

https://ibb.co/k1rctsZ

Same problem solved after delleting folders
public/vendor/tcg/voyager/
and update
config/voyager.php
as indicated in the documentation
https://docs.laravelvoyager.com/getting-started/upgrading

@cotiga
I just tried a fresh installation, translations of simple Text and Textboxes work, Rich-Text-translations don't.

https://youtu.be/oz7tbqUacqY

Just tested and faced the same issue.

On initial page load the hidden field for "_i18n" is providing the correct value format: {"zn":"","cn":""}

However, when you are selecting different language the value for the hidden "_i18n" changed to: {"cn":""} instead.

Anyone knows which file trigger this action? I wish to take a look.

I managed to resolve the issue by changing 1 line at resources/assets/js/multilingual.js file. Upon changing you will need to run the command "npm run dev" to generate a new app.js file at voyager vendor folder itself.

I have created a pull request for this at #4077 so please do verify if it does fix your issues as well.

@ohmygod8 works for me, made my day!

@jannescb I noticed that there is one more issue to fix.

If you purposely let the form to return error, and then you switch the language the old values of the default value will be replaced with the second language.

I am looking at it now.

Works for me too!!! Thanks!

any fix ? this problem with me from 4days ago

I've changed this file, run npm run dev but same bug. Any suggestions?

I made a little node script that fixes this by using _inp.siblings instead of _inp.next.
The script checks the version of voyager in composer.lock and exits if the version is different from 'v1.2.3' therefore it could theoretically be integrated in CI.
It also offers options for using yarn and restoring the original file.

https://gist.githubusercontent.com/mentAl-maZe/dbd7b3aa8b28679e22b37573fedc7f5f/raw/954d6833e4b3269932a53f95def5785b7144be91/voyager-fix.js

There is a short description in the comment of the gist

https://gist.github.com/mentAl-maZe/dbd7b3aa8b28679e22b37573fedc7f5f#gistcomment-2922836

This issue has been automatically locked since there has not been any recent activity after it was closed. If you have further questions please ask in our Slack group.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kevinjon27 picture kevinjon27  路  3Comments

duongsieu picture duongsieu  路  3Comments

winex01 picture winex01  路  3Comments

iwasherefirst2 picture iwasherefirst2  路  3Comments

popica80 picture popica80  路  3Comments