Below is a changed calendar() function from date.php which will fix the bug (I think it is anyhow) in the Date element. I.e. When the Date element it is set as ?readonly? ( ?Allow typing in field? set to ?No?), the image for triggering the calendar datepicker popup should not even be shown, as it only confuses the user. This fixes that.
Hiding the datepicker image button, if readonly, was just a matter of adding 3 variables.
I hope someone can fix that in the github. ...please... and thanks in advance.
Hiding the datepicker image button, if readonly, was just a matter of adding 3 variables.
- The $readonly var to determine if the element is set to readonly.
- The $hide var is used to add the fabrikHide class if readonly.
- The $class var is set the appropriate class to restore the rounded corners on the right of the input if the button is hidden.
PHP:
public function calendar($value, $name, $id, $format = '%Y-%m-%d', $attribs = null, $repeatCounter = 0)
{
FabrikHelperHTML::loadcalendar();
$j3 = FabrikWorker::j3();
$readonly = (is_array($attribs) && $attribs['readonly'] == 'readonly') ? "readonly" : "";
if (is_array($attribs))
{
$attribs = JArrayHelper::toString($attribs);
}
$paths = FabrikHelperHTML::addPath(COM_FABRIK_BASE . 'media/system/images/', 'image', 'form', false);
$opts = $j3 ? array('alt' => 'calendar') : array('alt' => 'calendar', 'class' => 'calendarbutton', 'id' => $id . '_cal_img');
$img = FabrikHelperHTML::image('calendar.png', 'form', @$this->tmpl, $opts);
$html = array();
if ($j3)
{
$hide = (empty($readonly)) ? "" : " fabrikHide";
$class = ($hide == "") ? "input-append" : "input";
$img = '<button id ="' . $id . '_cal_img" class="btn calendarbutton'.$hide.'">' . $img . '</button>';
$html[] = '<div class="'.$class.'">';
}
$html[] = '<input type="text" name="' . $name . '" id="' . $id . '" value="' . $value . '" ' . $attribs . ' />' . $img;
if ($j3)
{
$html[] = '</div>';
}
return implode("\n", $html);
}
I hope someone can fix that in the github. ...please... and thanks in advance.