public function render($module, $model) { $rtn = "\n[[[\r\n \$prepopulate = (\$object->isNew() ? (isset(\$_POST['" . $this->name . "']) ? strip_tags(\$_POST['" . $this->name . "']) : '') : \$object->get" . DBObject::tableNameToClassName($this->name) . "() * 1000);\r\n \$alt_prepopulate = \$prepopulate;\r\n if (preg_match('/^\\d+\$/', \$prepopulate)) {\r\n \$alt_prepopulate = date('Y-m-d', \$prepopulate/1000);\r\n }\r\n]]]\n"; $id = get_random_string(5); $rtn .= "\n<div id='{$id}' class='form-group'>\r\n <label class='col-sm-2 control-label' for='{$this->name}'>{$this->name} " . ($this->required ? $this->mandatory_field : '') . "</label>\r\n <div class='col-sm-10'>\r\n <div class='input-group'>\r\n <span class='input-group-addon'><i class='fa fa-calendar'></i></span>\r\n <input disabled='disabled' value='[[[ echo htmlentities(str_replace('\\'', '\"', \$alt_prepopulate)) ]]]' type='text' class='form-control altFormat' " . ($this->required ? ' required' : '') . " />\r\n <input value='[[[ echo htmlentities(str_replace('\\'', '\"', \$prepopulate)) ]]]' type='text' id='{$this->name}' name='{$this->name}' class='datepicker form-control' " . ($this->required ? ' required' : '') . " style='position: absolute; top:0; left: 0; z-index: -1' />\r\n </div>\r\n </div>\r\n</div>\r\n<div class='hr-line-dashed'></div>\r\n"; $rtn .= "\r\n <script type='text/javascript'>\r\n \$('#{$id} .datepicker').datepicker({\r\n " . (isset($this->options['dateFormat']) ? 'dateFormat: ' . "'" . $this->options['dateFormat'] . "'" : '') . "\r\n " . (isset($this->options['altFormat']) ? ',altField: "#' . $id . ' .altFormat", altFormat: "' . $this->options['altFormat'] . '"' : '') . "\r\n " . (isset($this->options['changeMonth']) ? ',changeMonth: ' . $this->options['changeMonth'] : '') . "\r\n " . (isset($this->options['changeYear']) ? ',changeYear: ' . $this->options['changeYear'] : '') . "\r\n " . (isset($this->options['yearRange']) ? ',yearRange: ' . "'" . $this->options['yearRange'] . "'" : '') . "\r\n });\r\n \$('#{$id} .input-group-addon').css('cursor', 'pointer').on('click', function(){\r\n \$('#{$id} .datepicker').datepicker('show');\r\n });\r\n </script>\r\n"; return $rtn; }