J3 Issue ?
avatar boomsya
boomsya
26 Mar 2018

Joomla 3.6.5

<field name="avg_year" type="calendar" default="NOW" label="Year" description="" class="input-small" required="true" format="%Y" showtime="false" todaybutton="false" translateformat="false" />

  1. type "2018"
  2. save config
  3. after config page reloaded - field replaced with "1970"
avatar boomsya boomsya - open - 26 Mar 2018
avatar joomla-cms-bot joomla-cms-bot - change - 26 Mar 2018
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 26 Mar 2018
avatar boomsya boomsya - change - 26 Mar 2018
Title
config.xml type="calendar" enter only year
config.xml type="calendar" enter only year replacing with 1970
avatar boomsya boomsya - edited - 26 Mar 2018
avatar boomsya boomsya - change - 26 Mar 2018
The description was changed
avatar boomsya boomsya - edited - 26 Mar 2018
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 26 Mar 2018

Can you please update to latest Version?

avatar brianteeman brianteeman - change - 26 Mar 2018
Status New Closed
Closed_Date 0000-00-00 00:00:00 2018-03-26 08:12:58
Closed_By brianteeman
avatar brianteeman brianteeman - close - 26 Mar 2018
avatar franz-wohlkoenig franz-wohlkoenig - change - 26 Mar 2018
Status Closed New
Closed_Date 2018-03-26 08:12:58
Closed_By brianteeman
Build staging 3.6.5
avatar joomla-cms-bot joomla-cms-bot - change - 26 Mar 2018
Closed_Date 0000-00-00 00:00:00
Build 3.6.5 staging
avatar joomla-cms-bot joomla-cms-bot - reopen - 26 Mar 2018
avatar joomla-cms-bot
joomla-cms-bot - comment - 26 Mar 2018
avatar franz-wohlkoenig franz-wohlkoenig - change - 26 Mar 2018
Category Fields
avatar franz-wohlkoenig franz-wohlkoenig - change - 26 Mar 2018
Status New Information Required
avatar boomsya
boomsya - comment - 26 Mar 2018

in DB table #__extensions
field "params" is "{"avg_year":"2018"}"

avatar boomsya
boomsya - comment - 26 Mar 2018

i will try to reproduce on 3.8.6 on other site

avatar boomsya
boomsya - comment - 26 Mar 2018

in Joomla 3.8.6 another behaviour: Joomla always set field to "2018" from "2017" before saving form and params DB field is {"avg_year":"2018"}

when i clicking "Save" button - input field with value "2017" always replacing automatically to 2018 before form sended to server and saved value DB is "2018"

so error still in latest version too. But with other behaviour

avatar boomsya
boomsya - comment - 26 Mar 2018

when config.xml field param format="%Y-%m" in Joomla 3.6.5 - saved value is correctly
but it is not what i want

avatar boomsya
boomsya - comment - 26 Mar 2018

and other error in 3.6.5 happens when i set format="%m-%Y"
DateTime::__construct(): Failed to parse time string (01-2018) at position 0 (0): Unexpected character

avatar brianteeman
brianteeman - comment - 26 Mar 2018

Any tests in 3.6.5 are irrelevant as you should only be using 3.8.6 and that is the only version supported

avatar brianteeman brianteeman - change - 26 Mar 2018
Labels Added: J3 Issue
avatar brianteeman brianteeman - labeled - 26 Mar 2018
avatar ggppdk
ggppdk - comment - 26 Mar 2018

@dgt41

In date-helper.js
method
Date.parseFieldDate

cannot handle format with only Year ?

avatar dgt41
dgt41 - comment - 26 Mar 2018

@ggppdk not sure that this is failing at the parser:

if (isNaN(y)) y = today.getFullYear();
if (isNaN(m)) m = today.getMonth();
if (isNaN(d)) d = today.getDate();
if (isNaN(hr)) hr = today.getHours();
if (isNaN(min)) min = today.getMinutes();
if (isNaN(sec)) sec = today.getSeconds();
if (y != 0 && m != -1 && d != 0)
return new Date(y, m, d, hr, min, sec);

it might be the print function that is failing but this needs to be debugged to figure out which part is failing. Fwiw both parse and print were not changed in any way when we redid the calendar...

avatar brianteeman
brianteeman - comment - 26 Mar 2018

Why would you even use a full calendar if you only want the year?

avatar ggppdk
ggppdk - comment - 26 Mar 2018

yes it seems that this code was not changed

i see that m (month) keeps its initial value -1 when you have format "%Y"
the parsing code continues
and eventually you get to have "return today";

Date.parseFieldDate = function(str, fmt, dateType) {
....
		var today = new Date();
		var y = 0;
		var m = -1;
		var d = 0;
...
		if (y != 0 && m != -1 && d != 0)
			return new Date(y, m, d, hr, min, sec);
...
		if (m != -1 && d != 0)
			return new Date(y, m, d, hr, min, sec);
		return today;
avatar ggppdk
ggppdk - comment - 26 Mar 2018

Why would you even use a full calendar if you only want the year?

indeed calendar field does not seem appropriate choice if you only want to select a year

avatar boomsya
boomsya - comment - 27 Mar 2018

Why would you even use a full calendar if you only want the year?

because i want. It is normal select year, month with only mouse. Why android using CalendarView? :) everyone can enter date in TextView :) because it is friendly UI. But calendar in Joomla it is pain.
Look at this http://t1m0n.name/air-datepicker/docs/index.html
it is datepicker on steroids :) in compare to joomla calendar

avatar mbabker
mbabker - comment - 27 Mar 2018

Even if the code's busted, this is a case where you're using an inefficient tool for the job. If you really only are offering a year selection and not a full date, you're better off creating a list field with a custom year range than trying to use a calendar to select a year.

avatar infograf768
infograf768 - comment - 27 Mar 2018

Look at this http://t1m0n.name/air-datepicker/docs/index.html
it is datepicker on steroids :) in compare to joomla calendar

Nice, but limited to Gregorian calendar. Joomla also includes jalali. ?

avatar ggppdk
ggppdk - comment - 27 Mar 2018

A drop down for year only selection will also be better ux, fast and easy, understandable

avatar boomsya
boomsya - comment - 28 Mar 2018

oh mans. i have some trouble with speaking english. Ok, i will try to explain:

  1. hardcoded values in dropdown list - is not very good.
  2. writing custom "element"? - maybe it is solution. maybe. But good solution is use core based CMS elements
  3. about Jalali and Gregorian - oh, i never saw this. Anybody using this? :) it is just question :)

anyway i hope my exploring with Year format helps somebody

avatar ggppdk
ggppdk - comment - 28 Mar 2018

hardcoded values in dropdown list - is not very good.

you can use this
https://docs.joomla.org/Number_form_field_type

about hardcoding, how is it different than specifying minyear maxyear in calendar filed ?
with hard-coding you mean you want different limits per which case ? different limit per language ?

avatar boomsya
boomsya - comment - 28 Mar 2018

thanks for solution

i mean what if i will hardcode dropdown in XML:
2016
2017
2018

and after 2-3 years i will need to add in XML:
2019
2020
2021
:(

avatar ggppdk
ggppdk - comment - 28 Mar 2018

Yes, i see the problem, indeed you need the minyear , maxyear options that the calendar supports

... then extending number form element type of Joomla and customizing it is the way to go

and regardless of fixing the issue you reported here, the above is probably the best UX choice (for the form)

in a previous answer, i mentioned where the issue is,
if someone is interested into spend time to fix it
#19993 (comment)

avatar infograf768
infograf768 - comment - 28 Mar 2018

about Jalali and Gregorian - oh, i never saw this. Anybody using this? :) it is just question :)

We have 2 languages using Jalali: Persian and Dari Persian

avatar tonypartridge
tonypartridge - comment - 6 Apr 2018

Just create a custom element type based on select list which has a starting year and goes 4 years into the future from today. Fairly simple to do, the core calendar isn’t really designed for your usage case, the core cannot think of every use age scenario.

avatar franz-wohlkoenig franz-wohlkoenig - change - 7 Apr 2018
Status Information Required Discussion
avatar Quy Quy - change - 22 Apr 2018
Status Discussion Closed
Closed_Date 0000-00-00 00:00:00 2018-04-22 14:29:12
Closed_By Quy
avatar joomla-cms-bot joomla-cms-bot - change - 22 Apr 2018
Closed_By Quy joomla-cms-bot
avatar joomla-cms-bot joomla-cms-bot - close - 22 Apr 2018
avatar joomla-cms-bot
joomla-cms-bot - comment - 22 Apr 2018

Set to "closed" on behalf of @Quy by The JTracker Application at issues.joomla.org/joomla-cms/19993

avatar Quy
Quy - comment - 22 Apr 2018

Closing for reasons stated above.


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

Add a Comment

Login with GitHub to post a comment