No Code Attached Yet bug
avatar KallertPa
KallertPa
28 Apr 2021

Steps to reproduce the issue

The following steps can be recreated in most places in the code since it concerns a layout. I have added the code at the beginning of the file index.php in the frontend template.

  1. Set locale to de_DE with setlocale(LC_ALL, 'de_DE');
  2. Create an array with the values required for the layout joomla.form.field.number. This could be for example: $array= array('value' => "34.3", 'autocomplete' => false, 'disabled' => false, 'hint' => '', 'required' => false, 'autofocus' => false, 'readonly' => false );
  3. Call the layout joomla.form.field.number and pass the array to the layout. Code example: echo JLayoutHelper::render('joomla.form.field.number', $array);

Expected result

A input field of type number with the value 34.3

Actual result

A input field of type number without any values set (see attached Screenshot)

System information (as much as possible)

Tested on a new installation of Joomla 3.9.26 Stable on local and a hosted webserver.
Tested with the latest Chrome and Firefox.

Additional comments

Apparently casting the value to float with the locale set to de_DE will create a number with a comma instead of a point. This is then not accepted by the input field of type number, which in most browsers only accepts floats with points.

screen shot 2021-04-28 at 09 52 25

Votes

# of Users Experiencing Issue
2/2
Average Importance Score
4.00

avatar KallertPa KallertPa - open - 28 Apr 2021
avatar joomla-cms-bot joomla-cms-bot - labeled - 28 Apr 2021
avatar KallertPa KallertPa - change - 28 Apr 2021
The description was changed
avatar KallertPa KallertPa - edited - 28 Apr 2021
avatar ReLater
ReLater - comment - 28 Apr 2021

Actual result. A input field of type number without any values set (see attached Screenshot)

Can't confirm with Joomla 3.9.27-dev, PHP7.4, Protostar, with or without setlocale, FireFox:

<!-- Body -->
 <div class="body" id="top">
  <div class="container<?php echo ($params->get('fluidContainer') ? '-fluid' : ''); ?>">
<?php
// setlocale(LC_ALL, 'de_DE');

$array= array('value' => "34.3", 'autocomplete' => false, 'disabled' => false, 'hint' => '', 'required' => false, 'autofocus' => false, 'readonly' => false );

echo JLayoutHelper::render('joomla.form.field.number', $array);
?>
 <!-- Header -->

28-04-_2021_13-59-03

avatar rafal-nagorski
rafal-nagorski - comment - 4 May 2021

I have the same problem with the comma instead of the point on Joomla 3.9.26 and 3.9.27-devdev.

In two different hosting companies, two different Joomla's, after entering setlocale(LC_ALL, 'pl_PL');, I have commas instead of the point.


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

avatar ReLater
ReLater - comment - 4 May 2021

I've tested only:

A input field of type number without any values set (see attached Screenshot)`

I have commas instead of the point.

That's what I expect on a (my) German website. And I didn't get any "invalid" hint with Firefox when I left the field via Tab.

Therefore you must describe the issue/testing instructions more precisely.

avatar rafal-nagorski
rafal-nagorski - comment - 5 May 2021

I noticed this problem in RSForm and reCAPTCHA V3 plugin on client hosting.
Everything worked fine on my hosting.
I started looking for a solution to the problem with the plug-in manufacturer and then in hosting.
Hosting told me to add setlocale (LC_ALL, 'en_US.utf8'); to index.php and it worked.

Then I started looking for a problem with Joomla setlocale and that's how I ended up here.

Now I tested according to your instructions in the Protostar template and it does not work in Chrome, Opera, Safari, Brave (blank field).
Only works in Firefox (apparently accepts commas in fractions).


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

avatar OctavianC
OctavianC - comment - 5 May 2021

I can reproduce this on Windows by using:
setlocale(LC_ALL, 'Polish');

On a shared hosting environment (CentOS) I can reproduce this with:
setlocale(LC_ALL, 'pl_PL');

This happens on PHP < 8 only. With PHP 8+ there are some changes documented here:
https://php.watch/versions/8.0/float-to-string-locale-independent
Which is in my opinion a feature that has been fixed: PHP shouldn't globally change and localize output on its own. I don't really see a way to fix this in Joomla! at this point

avatar ReLater
ReLater - comment - 5 May 2021

This happens on PHP < 8 only.

I can confirm your find in some other browsers than Firefox. PHP < 8. Whenever a setlocale is used in my example above the field is empty. PHP8: all fine.

On the other hand I don't need a setlocale. Any browser shows me a comma instead of a dot on a German site. But maybe I'm missing something. Saving does not work or whatever?

avatar rafal-nagorski
rafal-nagorski - comment - 5 May 2021

Forms with fractions do not work on some shared servers in Poland.!
(https://issues.joomla.org/uploads/1/d1dfa4148ee221ea207f08ceed0106f1.png)


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

avatar Hackwar Hackwar - change - 22 Feb 2023
Labels Added: No Code Attached Yet bug
Removed: ?
avatar Hackwar Hackwar - labeled - 22 Feb 2023

Add a Comment

Login with GitHub to post a comment