Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F1046477
D201.id487.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Jun 28, 7:26 PM
Size
3 KB
Mime Type
text/x-diff
Expires
Sun, Jun 29, 7:26 PM (9 h, 56 m)
Engine
blob
Format
Raw Data
Handle
676523
Attached To
D201: INP-1531 Allow specifying default date/time for "inp_edit_date_time" control
D201.id487.diff
View Options
Index: core/admin_templates/incs/form_blocks.tpl
===================================================================
--- core/admin_templates/incs/form_blocks.tpl
+++ core/admin_templates/incs/form_blocks.tpl
@@ -440,7 +440,7 @@
title="Date selector"
/>
<span class="small">(<inp2:{$prefix}_Format field="{$field}_date" input_format="1" human="true"/>)</span>
- <input type="hidden" id="full_date_<inp2:{$prefix}_InputName field='{$field}'/>" value="<inp2:{$prefix}_Field field='{$field}' format=''/>" />
+ <input type="hidden" id="full_date_<inp2:{$prefix}_InputName field='{$field}'/>" value="<inp2:{$prefix}_Field field='{$field}' format='picker'/>" />
<script type="text/javascript">
Calendar.setup({
inputField : "full_date_<inp2:{$prefix}_InputName field='{$field}'/>",
Index: core/kernel/utility/formatters/date_formatter.php
===================================================================
--- core/kernel/utility/formatters/date_formatter.php
+++ core/kernel/utility/formatters/date_formatter.php
@@ -232,46 +232,58 @@
/**
* Formats value of a given field
*
- * @param string $value
- * @param string $field_name
- * @param kDBItem|kDBList $object
- * @param string $format
+ * @param string $value Value.
+ * @param string $field_name Field name.
+ * @param kDBBase $object Object.
+ * @param string $format Format.
+ *
* @return string
*/
- function Format($value, $field_name, &$object, $format=null)
+ public function Format($value, $field_name, kDBBase &$object, $format = null)
{
- if ( is_null($value) ) return '';
+ $options = $object->GetFieldOptions($field_name);
+
+ if ( is_null($value) ) {
+ if ( $format != 'picker' || !isset($options['picker_default']) ) {
+ return '';
+ }
+
+ $value = strtotime($options['picker_default']);
+ $format = null;
+ }
+
if ( !is_numeric($value) ) {
return $value; // for leaving badly formatted date on the form
}
+
settype($value, 'int');
+
if ( !is_int($value) ) {
return $value;
}
- $options = $object->GetFieldOptions($field_name);
if ( isset($format) ) {
$options['format'] = $format;
}
- if (preg_match('/_regional_(.*)/', $options['format'], $regs)) {
+ if ( preg_match('/_regional_(.*)/', $options['format'], $regs) ) {
// when such type of format is given directly to kDBBase::GetField
$options['format'] = $this->language->GetDBField($regs[1]);
}
- if ($options['format'] == '_input_') {
+ if ( $options['format'] == '_input_' ) {
// use input format instead of output format
$options['format'] = $options['input_format'];
}
- if (!$options['use_timezone']) {
+ if ( !$options['use_timezone'] ) {
return gmdate($options['format'], $value);
}
$format = defined($options['format']) ? constant($options['format']) : $options['format'];
$dt_separator = getArrayValue($options, 'date_time_separator');
- if ($dt_separator) {
+ if ( $dt_separator ) {
$format = trim($format, $dt_separator);
}
@@ -506,4 +518,4 @@
{
return $this->Format( time(), $field, $object, $options['input_format']);
}
-}
\ No newline at end of file
+}
Event Timeline
Log In to Comment