1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-06 14:46:56 +02:00

Fix for datepicker(). Tested!

This commit is contained in:
lonalore
2016-06-09 10:18:41 +02:00
parent 5a820eaf52
commit f1846dc955

View File

@@ -966,7 +966,6 @@ class e_form
*/
function datepicker($name, $datestamp = false, $options = null)
{
if(vartrue($options) && is_string($options))
{
parse_str($options,$options);
@@ -976,7 +975,10 @@ class e_form
$dateFormat = varset($options['format']) ? trim($options['format']) :e107::getPref('inputdate', '%Y-%m-%d');
$ampm = (preg_match("/%l|%I|%p|%P/",$dateFormat)) ? 'true' : 'false';
$value = null;
$hiddenValue = null;
$useUnix = (isset($options['return']) && ($options['return'] === 'string')) ? 'false' : 'true';
$id = $this->name2id($name);
$classes = array('date' => 'e-date', 'datetime' => 'e-datetime');
if($type == 'datetime' && !varset($options['format']))
{
@@ -985,10 +987,6 @@ class e_form
$dformat = e107::getDate()->toMask($dateFormat);
$id = $this->name2id($name);
$classes = array('date' => 'e-date', 'datetime' => 'e-datetime');
// If default value is set.
if ($datestamp)
{
@@ -998,13 +996,15 @@ class e_form
}
// Convert date to proper (selected) format.
$value = e107::getDate()->convert_date($datestamp, $dformat);
$hiddenValue = $value = e107::getDate()->convert_date($datestamp, $dformat);
if ($useUnix === 'true')
{
$hiddenValue = $datestamp;
}
}
$text = "";
// $text .= 'dformat='.$dformat.' defdisp='.$dateFormat;
$class = (isset($classes[$type])) ? $classes[$type] : "tbox e-date";
$size = vartrue($options['size']) ? intval($options['size']) : 40;
@@ -1024,7 +1024,7 @@ class e_form
$text .= "<input class='{$class} input-".$xsize." form-control' type='text' size='{$size}' id='e-datepicker-{$id}' value='{$value}' data-date-unix ='{$useUnix}' data-date-format='{$dformat}' data-date-ampm='{$ampm}' data-date-language='".e_LAN."' data-date-firstday='{$firstDay}' {$required} {$disabled} />";
$ftype = (!empty($options['debug'])) ? 'text' : 'hidden';
$text .= "<input type='{$ftype}' name='{$name}' id='{$id}' value='{$value}' />";
$text .= "<input type='{$ftype}' name='{$name}' id='{$id}' value='{$hiddenValue}' />";
}
// $text .= "ValueFormat: ".$dateFormat." Value: ".$value;