? Pending

User tests: Successful: Unsuccessful:

avatar nikosdion
nikosdion
31 May 2020

Closes gh-29340

Pull Request for Issue #29340 .

Summary of Changes

Fixes https://github.com/joomla/joomla-cms/blob/4.0-dev/layouts/joomla/form/field/calendar.php#L117 to stop emitting a PHP Notice when you display a Calendar field with HtmlHelper.

Testing Instructions

Set error reporting to Maximum.

Use any extension which uses something similar to

echo \Joomla\CMS\HTML\HTMLHelper::('calendar', $myDate, 'fieldName', 'fieldID');

such as Akeeba Backup Core, Manage Backups tab.

Expected result

Calendar (date picker) fields displayed without an issue.

Actual result

You see "Notice: Undefined variable: dataAttribute in ...../layouts/joomla/form/field/calendar.php on line 117" in the middle of the calendar field. The effect is more pronounced and disruptive if you have XDebug enabled.

Documentation Changes Required

None.

avatar nikosdion nikosdion - open - 31 May 2020
avatar nikosdion nikosdion - change - 31 May 2020
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 31 May 2020
Category Layout
avatar dgrammatiko
dgrammatiko - comment - 31 May 2020

@nikosdion although your code will solve the undefined variable error probably is not solving the root problem which is the parent function doesn't spit that variable. I guess a more robust approach is to add also the data-attributes part here

$readonly = isset($attribs['readonly']) && $attribs['readonly'] === 'readonly';
$disabled = isset($attribs['disabled']) && $attribs['disabled'] === 'disabled';
$autocomplete = isset($attribs['autocomplete']) && $attribs['autocomplete'] === '';
$autofocus = isset($attribs['autofocus']) && $attribs['autofocus'] === '';
$required = isset($attribs['required']) && $attribs['required'] === '';
$filter = isset($attribs['filter']) && $attribs['filter'] === '';
$todayBtn = $attribs['todayBtn'] ?? true;
$weekNumbers = $attribs['weekNumbers'] ?? true;
$showTime = $attribs['showTime'] ?? false;
$fillTable = $attribs['fillTable'] ?? true;
$timeFormat = $attribs['timeFormat'] ?? 24;
$singleHeader = $attribs['singleHeader'] ?? false;
$hint = $attribs['placeholder'] ?? '';
$class = $attribs['class'] ?? '';
$onchange = $attribs['onChange'] ?? '';
$minYear = $attribs['minYear'] ?? null;
$maxYear = $attribs['maxYear'] ?? null;
$showTime = ($showTime) ? "1" : "0";
$todayBtn = ($todayBtn) ? "1" : "0";
$weekNumbers = ($weekNumbers) ? "1" : "0";
$fillTable = ($fillTable) ? "1" : "0";
$singleHeader = ($singleHeader) ? "1" : "0";

@wilsone get someone to review all the HTML helpers for the missing data attribute code. This will be the case not only for the calendar

avatar wilsonge
wilsonge - comment - 31 May 2020

get someone to review all the HTML helpers for the missing data attribute code. This will be the case not only for the calendar

Just did a review this is the only place we seem to be calling one of the form fields layouts.

Just to cover all aspects I've directly pushed a change fixing this in the HTMLHelper too tho with 4500d21

avatar wilsonge wilsonge - change - 31 May 2020
Status Pending Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2020-05-31 20:55:03
Closed_By wilsonge
Labels Added: ?
avatar wilsonge wilsonge - close - 31 May 2020
avatar wilsonge wilsonge - merge - 31 May 2020
avatar wilsonge
wilsonge - comment - 31 May 2020

Thanks!

avatar dgrammatiko
dgrammatiko - comment - 31 May 2020

@wilsonge but 4500d21 just disables the ability to set any data attributes. At least put a todo there so someone might pick it up

Add a Comment

Login with GitHub to post a comment