/**
* Method to attach a Form object to the field.
*
* @param \SimpleXMLElement $element The SimpleXMLElement object representing the `<field>` tag for the form field object.
* @param mixed $value The form field value to validate.
* @param string $group The field name group control value. This acts as an array container for the field.
* For example if the field has name="foo" and the group value is set to "bar" then the
* full field name would end up being "bar[foo]".
*
* @return boolean True on success.
*
* @see FormField::setup()
* @since 3.2
*/
public function setup(\SimpleXMLElement $element, $value, $group = null)
{
$return = parent::setup($element, $value, $group);
if ($return) {
$this->maxlength = (int) $this->element['maxlength'] ? (int) $this->element['maxlength'] : 45;
$this->format = (string) $this->element['format'] ? (string) $this->element['format'] : '%Y-%m-%d';
$this->filter = (string) $this->element['filter'] ? (string) $this->element['filter'] : 'USER_UTC';
$this->todaybutton = (string) $this->element['todaybutton'] ? (string) $this->element['todaybutton'] : 'true';
$this->weeknumbers = (string) $this->element['weeknumbers'] ? (string) $this->element['weeknumbers'] : 'true';
$this->showtime = (string) $this->element['showtime'] ? (string) $this->element['showtime'] : 'false';
$this->filltable = (string) $this->element['filltable'] ? (string) $this->element['filltable'] : 'true';
$this->timeformat = (int) $this->element['timeformat'] ? (int) $this->element['timeformat'] : 24;
$this->singleheader = (string) $this->element['singleheader'] ? (string) $this->element['singleheader'] : 'false';
$this->minyear = \strlen((string) $this->element['minyear']) ? (string) $this->element['minyear'] : null;
$this->maxyear = \strlen((string) $this->element['maxyear']) ? (string) $this->element['maxyear'] : null;
if ($this->maxyear < 0 || $this->minyear > 0) {
$this->todaybutton = 'false';
}
$translateFormat = (string) $this->element['translateformat'];
if ($translateFormat && $translateFormat !== 'false') {
$showTime = (string) $this->element['showtime'];
$lang = Factory::getLanguage();
$debug = $lang->setDebug(false);
if ($showTime && $showTime !== 'false') {
$this->format = Text::_('DATE_FORMAT_CALENDAR_DATETIME');
$this->filterFormat = Text::_('DATE_FORMAT_FILTER_DATETIME');
} else {
$this->format = Text::_('DATE_FORMAT_CALENDAR_DATE');
$this->filterFormat = Text::_('DATE_FORMAT_FILTER_DATE');
}
$lang->setDebug($debug);
}
}
return $return;
}