mirror of
https://github.com/e107inc/e107.git
synced 2025-08-06 22:57:14 +02:00
Fix for datepicker(). Tested!
This commit is contained in:
@@ -966,7 +966,6 @@ class e_form
|
|||||||
*/
|
*/
|
||||||
function datepicker($name, $datestamp = false, $options = null)
|
function datepicker($name, $datestamp = false, $options = null)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(vartrue($options) && is_string($options))
|
if(vartrue($options) && is_string($options))
|
||||||
{
|
{
|
||||||
parse_str($options,$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');
|
$dateFormat = varset($options['format']) ? trim($options['format']) :e107::getPref('inputdate', '%Y-%m-%d');
|
||||||
$ampm = (preg_match("/%l|%I|%p|%P/",$dateFormat)) ? 'true' : 'false';
|
$ampm = (preg_match("/%l|%I|%p|%P/",$dateFormat)) ? 'true' : 'false';
|
||||||
$value = null;
|
$value = null;
|
||||||
|
$hiddenValue = null;
|
||||||
$useUnix = (isset($options['return']) && ($options['return'] === 'string')) ? 'false' : 'true';
|
$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']))
|
if($type == 'datetime' && !varset($options['format']))
|
||||||
{
|
{
|
||||||
@@ -985,10 +987,6 @@ class e_form
|
|||||||
|
|
||||||
$dformat = e107::getDate()->toMask($dateFormat);
|
$dformat = e107::getDate()->toMask($dateFormat);
|
||||||
|
|
||||||
$id = $this->name2id($name);
|
|
||||||
|
|
||||||
$classes = array('date' => 'e-date', 'datetime' => 'e-datetime');
|
|
||||||
|
|
||||||
// If default value is set.
|
// If default value is set.
|
||||||
if ($datestamp)
|
if ($datestamp)
|
||||||
{
|
{
|
||||||
@@ -998,13 +996,15 @@ class e_form
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Convert date to proper (selected) format.
|
// 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 = "";
|
||||||
// $text .= 'dformat='.$dformat.' defdisp='.$dateFormat;
|
|
||||||
|
|
||||||
$class = (isset($classes[$type])) ? $classes[$type] : "tbox e-date";
|
$class = (isset($classes[$type])) ? $classes[$type] : "tbox e-date";
|
||||||
$size = vartrue($options['size']) ? intval($options['size']) : 40;
|
$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} />";
|
$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';
|
$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;
|
// $text .= "ValueFormat: ".$dateFormat." Value: ".$value;
|
||||||
|
Reference in New Issue
Block a user