Skip to content

Commit

Permalink
fixed: Date element in repeated group, when group set to not use
Browse files Browse the repository at this point in the history
duplicate source groups data. Default date not applied to date element
  • Loading branch information
pollen8 committed Aug 1, 2014
1 parent 44c4309 commit 468c0ce
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion plugins/fabrik_element/date/date.php
Expand Up @@ -832,7 +832,9 @@ public function elementJavascript($repeatCounter)
$id = $this->getHTMLId($repeatCounter);
$opts = $this->getElementJSOptions($repeatCounter);
$opts->hidden = (bool) $this->getElement()->hidden;
$opts->defaultVal = $this->offsetDate;

// Used uniquely in reset();
$opts->defaultVal = $this->getFrontDefaultValue();
$opts->showtime = (!$element->hidden && $params->get('date_showtime', 0)) ? true : false;
$opts->timelabel = FText::_('time');
$opts->typing = (bool) $params->get('date_allow_typing_in_field', true);
Expand Down Expand Up @@ -2395,6 +2397,35 @@ public function formJavascriptClass(&$srcs, $script = '', &$shim = array())
// Return false, as we need to be called on per-element (not per-plugin) basis
return false;
}


/**
* Get the Front end JS default date
*
* @param array $data Form data
*
* @return string
*/

public function getFrontDefaultValue($data = array())
{
$params = $this->getParams();
$db = JFactory::getDbo();
$alwaysToday = $params->get('date_alwaystoday', false);
$defaultToday = $params->get('date_defaulttotoday', false);
$formModel = $this->getFormModel();

if ($alwaysToday || $defaultToday)
{
$this->default = JHtml::_('date', 'now', $db->getDateFormat());
}
else
{
$this->default = parent::getDefaultValue($data);
}

return $this->default;
}
}

/**
Expand Down Expand Up @@ -2583,4 +2614,5 @@ protected function stripDays($str)

return $str;
}

}

0 comments on commit 468c0ce

Please sign in to comment.