Closed bastienrobert closed 5 years ago
Ok, I found the bug. In the form.blade.php
layout, the line:
published: {{ json_encode(isset($item) ? $item->published : false) }},
returns "0"
So, I migrate my db from sqlite to postgresql. It works.
I have just run into this issue when publishing my application to a production environment. Does anyone have any fixes other than @bastienrobert migrating from sqlite to postgresql?
I'm now using MariaDB, still no problem. The issue seems to come from sqlite.
@bastienrobert Must also be an issue with mysql as that is what I am using. Hesitant to have to migrate as I have populated over 100 records on local with no issues, its only when I publish to the production environment.
Hi @benmacgowan, MySQL shouldn't be the issue here. Can you share more about your error? Do you have something in your Laravel log? In the browser console?
Hi @ifox
Browser console shows the following whenever loading the edit form (for all modules):
Nothing seems to be appearing in the Laravel logs.
Yep, got exactly the same under SQLite but I don’t have this issue anymore with maria 🙃
Hi! I also have the same error but it is not related to MySQL. In my local machine it is working just fine. The error appeared after I published on the server (cloudlinux, MariaDB 10.1.38, PHP 7.2 - cPanel).
As you probably know .. cPanel has the public_html folder so I have created another folder on the account root where I have uploaded everything except the "public" folder ... The "public" folder contents I have uploaded to the "public_html" folder in my cPanel account. I have done all necessary changes to reflect the new public_path() ... and everything is working fine both in frontend and the Twill's admin ... except the "EDIT" form. I can create new models ... but the edit part is same as @benmacgowan reported.
Chrome's reported error in vendor.js:
var d, p = {
state: {
crops: window.STORE.medias.crops || {},
types: window.STORE.medias.types || [],
type: "image"
The page however has a tag where "window.STORE.medias.crops" is initialized. So I do not know where to look. Anybody got this fixed? Thank you!
What sounded like it wasn't a DB issue actually ended up being one for Ben. The charset of the DB he exported from was different from the DB he imported it in. Ben ended up setting up a server through Forge. But you should be able to match charset on both environments. Can you confirm you imported your database and didn't set it up through fresh Laravel migrations?
Hi Quentin! I confirm I did mysql import. I have exported it from my local dev and imported on the prod server... both using utf8mb4_unicode_ci collation.
Ok! Can you share a gist of the HTML source of your edit page?
I have sent you to your email address more info.
Hi .. again! I think I've found the issue ... at least for me ... In the blade template twill/layouts/form.blade.php there are some JS ojects that are initialized like below:
window.STORE.publication = {
withPublicationToggle: {{ json_encode(($publish ?? true) && isset($item) && $item->isFillable('published')) }},
published: {{ json_encode(isset($item) ? $item->published : false) }},
Please notice: {{ json_encode ... is using {{ instead of {!! therefore the single quote is encoded to "e; in the generated html page... and the error breaks loose afterwards....
Hope this is helpful for somebody.
For me it was the PHP version, on PHP 7.3 it seems to generate this error. I tested this on multiple hosting instances and it breaks when I am using 7.3 no matter what database I use.
I have MySQL 8 database on VPS and I use external connection from my shared hoster. (because I wanted to test if it was the database) and it still didn't work. (even though the database was working on the other shared hostings...) so than I changed php 7.3 to 7.1 and BOEM. This error is gone... In composer.json it does require this version of php but I did not get any warning or whatsoever.
I don't know if Twill should fix this or Laravel but maybe someone can look in this? :) @ifox
Hey guys,
I ran into the same issue like @adelinferaru when I was deploying from dev to prod. The error message was a little different: TypeError: window.STORE is undefined
. First i tried @vacoup95 solution but nothing changed. I also checked the collation. All good.
In the end, I was able to fix the problem with the help of this comment.: https://github.com/area17/twill/issues/180#issuecomment-488345322
Don't know if there is a relation, but the hoster which I have to use provide only mysql 5.6 so I'm force to use longtext instead of json.
Hi .. again! I think I've found the issue ... at least for me ... In the blade template twill/layouts/form.blade.php there are some JS ojects that are initialized like below:
window.STORE.publication = { withPublicationToggle: {{ json_encode(($publish ?? true) && isset($item) && $item->isFillable('published')) }}, published: {{ json_encode(isset($item) ? $item->published : false) }},
Please notice: {{ json_encode ... is using {{ instead of {!! therefore the single quote is encoded to "e; in the generated html page... and the error breaks loose afterwards....
Hope this is helpful for somebody.
I had this exact issue. Replacing the {{ with {!! on json_encode methods fixed the thing.
If you have an issue with this, it has been fixed in v2.0 -> https://github.com/area17/twill/commit/1cafa780263e41bcb51c01e66d0da24c8213bf62
Its because getLanguageLabelFromLocaleCode() in _vendor\area17\twill\src\Helpers\i18nhelpers.php is using ucfirst in line 74 ucfirst(Locale::getDisplayLanguage($code, $code)).
Note that 'alphabetic' is determined by the current locale. For instance, in the default "C" locale characters such as umlaut-a (ä) will not be converted.
So when $code is 'zh-Hans' i.e. chinese simplified, it got translated by Locale::getDisplayLanguage($code, $code) to "中文" but ucfirst makes it b"ĸ文" .
In simple words its i18n error. Function getLanguageLabelFromLocaleCode($code, $native = false) can't get Language label from locale code.
@shabaz-ejaz Meanwhile you can change 2nd parameter to false on line 56: 'label' => getLanguageLabelFromLocaleCode($locale, true) in vendor\area17\twill\views\users\form.blade.php.
@ifox Please Fix it.
After upgrading past Twill 2.0.0, where this was introduced:
We also namespaced our inline javascript variables to prevent any conflict in the global window moving forward. [..] You should update to
window.TWILL.STORE
andwindow.TWILL.vm
or even better, usingwindow.{{ config('twill.js_namespace') }}
instead of directly usingwindow.TWILL
if you are in a Blade file andprocess.env.VUE_APP_NAME
if you are in a Vue file.
I made the changes suggested above, but the admin still wasn't loading, even after running twill:build
. I had this error:
TypeError: window.STORE is undefined
Running view:clear
fixed the issue. It looks like an old layouts/main.blade.php
got cached. twill:build
calls twill:update
, which runs cache:clear
, but it seems like that might not be enough in some cases?
Thanks for reporting @IllyaMoskvin, I think it would definitely make sense to include a view:clear
in the Twill build/update flow.
when i try active user.. i got " Your submission could not be processed."
Same problem as @Heqma here. Any solutions yet?
I'm following the documentation to add Twill (1.2.) on a fresh install (php ^7.1.3 & laravel 5.7.).
For now, I only set these env values on the .env:
And I setup the database to use sqlite3.
No problem with the installation, everything is going well. I've my administration credentials but when I'm trying to access to the dashboard settings, (it redirects me to
http://admin.localhost:8000/users/1/edit
but) the form is never appearing. The loader never stops. When I look at the DOM, the fields seem to be well generated.I think it's a DOM error. Here is the logs in the JS console.