?
avatar farzadtaheri
farzadtaheri
12 Jun 2017

Steps to reproduce the issue

1- make sure you have more than two category for articles(com_content)
2- make sure you have at least a field for articles with context: com_content.article in com_fields
3- change back-end language to Persian(fa-IR).
4- go to Content > Articles. in Persian language the path is: محتوا > مطالب
5- edit an article and change category field value to another one.
6- after change category field value you see an error: DateTime::__construct(): Failed to parse time string (۱۳۹۶-۰۳-۰۶ ۰۳:۳۶:۰۲) at position 0 (�): Unexpected character

Expected result

dont show any error and fully reload page after ajax call

Actual result

after change category field value you see an error: DateTime::__construct(): Failed to parse time string (۱۳۹۶-۰۳-۰۶ ۰۳:۳۶:۰۲) at position 0 (�): Unexpected character

System information (as much as possible)

Joomla 3.7.x
PHP 5.6, 7.0, 7.1

Additional comments

I resolve this problem by editing this file:
/media/system/js/fields/calendar-locales/fa-ir.js
and comment line 19 : //localLangNumbers: ["۰","۱","۲","۳","۴","۵","۶","۷","۸","۹"]

avatar farzadtaheri farzadtaheri - open - 12 Jun 2017
avatar joomla-cms-bot joomla-cms-bot - labeled - 12 Jun 2017
avatar dgt41
dgt41 - comment - 12 Jun 2017

@farzadtaheri commenting out the localisation string for numbers is not the right approach. The correct solution here will be to add this code:

		var elements = document.querySelectorAll(".field-calendar");

		for (var i = 0; i < elements.length; i++) {
			var element  = elements[i],
			    instance = element._joomlaCalendar;

			if (instance) {
				instance.setAltValue();
			}
		}

In the fields category change event

avatar franz-wohlkoenig franz-wohlkoenig - change - 12 Jun 2017
Priority Urgent Medium
Status New Discussion
avatar farzadtaheri
farzadtaheri - comment - 13 Jun 2017

@dgt41 yes it`s better idea.
I added the lines in this file:

administrator/components/com_fields/helpers/fields.php after line 345.

after this change error not shown again. :)

is that what you mean?

avatar infograf768
infograf768 - comment - 13 Jun 2017

Anyone making this PR?

avatar farzadtaheri
farzadtaheri - comment - 13 Jun 2017

when i use this lines i get JavaScript error because (element) variable used in other lines. so i change the lines to this for resolve problem:

			var elements = document.querySelectorAll(".field-calendar");

			for (var i = 0; i < elements.length; i++) {
				var calendarfield  = elements[i],
					instance = calendarfield._joomlaCalendar;

				if (instance) {
					instance.setAltValue();
				}
			}
avatar dgt41
dgt41 - comment - 13 Jun 2017

@farzadtaheri yup, that was what I was suggesting

avatar ViscountVic
ViscountVic - comment - 13 Jun 2017

I can confirm, solution working.
I added code after 345 line, but with little change:

var elements = document.querySelectorAll('.field-calendar');
                for (var i = 0; i < elements.length; i++) {
                    var calendarfield  = elements[i],
                        instance = calendarfield._joomlaCalendar;
                    if (instance) {
                        instance.setAltValue();
                    }
                }
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 13 Jun 2017

can one of you Guys wrote the PR?

avatar ViscountVic
ViscountVic - comment - 13 Jun 2017

I did PR - please look is all OK

avatar dgt41
dgt41 - comment - 13 Jun 2017

I am just pasting here my comments on @ViscountVic PR (which needs to be against Joomla's repo):

I would like to suggest a more decoupled snippet here (right now we are forcing calendar code into Fields and we actually fixing partially the problem, can still be a bug for other javascript dependant fields)
So here is my suggestion:

  • remove the added code
  • replace
element.form.submit();

with

var button = document.createElement('input');
button.style.display = 'none';
button.type = 'submit';
element.form.appendChild(button).click();

Now a proper submit event is bubbled and the calendar (or any script that needs to do anything before submitting a form) will process the data correctly.

PS Sorry for not suggesting this in the first place but I wasn't sure that this was the actual problem. By the way I tested the code and is working fine

avatar ViscountVic
ViscountVic - comment - 13 Jun 2017

New solution isn't working. I see animated icon without any result.

Please restore back previous solution.

avatar dgt41
dgt41 - comment - 13 Jun 2017

@ViscountVic what exactly is not working?

avatar farzadtaheri
farzadtaheri - comment - 14 Jun 2017

@dgt41 , hi, i think we can do this with more simple change,
i replace the line

element.form.submit();

with

Joomla.submitform('field.storeform', element.form);

and everything is work.

amazing!!
with this change no need to add this lines even!

var elements = document.querySelectorAll('.field-calendar');
                for (var i = 0; i < elements.length; i++) {
                    var calendarfield  = elements[i],
                        instance = calendarfield._joomlaCalendar;
                    if (instance) {
                        instance.setAltValue();
                    }
               }

so for resolve main issue we just need change one line only (348) and nothing else.

avatar ViscountVic
ViscountVic - comment - 14 Jun 2017

@dgt41 I changed category and page showing updating animate image with white transparent background, but it is not finished, all time this animation, without access for edit article

avatar dgt41
dgt41 - comment - 14 Jun 2017

@farzadtaheri if Joomla.submitform() works then that's a better solution!

avatar infograf768
infograf768 - comment - 16 Jun 2017

@farzadtaheri
Please make a PR vs staging so we can test and get this in for 3.7.3
Add the link to the PR here. Thanks.

avatar brianteeman
brianteeman - comment - 18 Aug 2017

Was this resolved?

avatar franz-wohlkoenig franz-wohlkoenig - change - 18 Aug 2017
Status Discussion Information Required
avatar farzadtaheri
farzadtaheri - comment - 4 Sep 2017

@brianteeman not yet, the problem change but not resolved! please check new PR #17859.

avatar franz-wohlkoenig franz-wohlkoenig - change - 17 Sep 2017
Status Information Required Closed
Closed_Date 0000-00-00 00:00:00 2017-09-17 10:59:42
Closed_By franz-wohlkoenig
avatar joomla-cms-bot joomla-cms-bot - change - 17 Sep 2017
Closed_By franz-wohlkoenig joomla-cms-bot
avatar joomla-cms-bot joomla-cms-bot - close - 17 Sep 2017
avatar joomla-cms-bot
joomla-cms-bot - comment - 17 Sep 2017
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 17 Sep 2017

closed as having Pull Request #17859


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/16628.

Add a Comment

Login with GitHub to post a comment