Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F1025961
D201.id.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
Fri, Jun 13, 5:33 PM
Size
3 KB
Mime Type
text/x-diff
Expires
Sat, Jun 14, 5:33 PM (4 h, 4 m)
Engine
blob
Format
Raw Data
Handle
661407
Attached To
D201: INP-1531 Allow specifying default date/time for "inp_edit_date_time" control
D201.id.diff
View Options
Index: branches/5.2.x/core/admin_templates/incs/form_blocks.tpl
===================================================================
--- branches/5.2.x/core/admin_templates/incs/form_blocks.tpl
+++ branches/5.2.x/core/admin_templates/incs/form_blocks.tpl
@@ -445,7 +445,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: branches/5.2.x/core/kernel/utility/formatters/date_formatter.php
===================================================================
--- branches/5.2.x/core/kernel/utility/formatters/date_formatter.php
+++ branches/5.2.x/core/kernel/utility/formatters/date_formatter.php
@@ -232,46 +232,61 @@
/**
* 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, &$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']);
+ }
+
+ if ( $format == 'picker' ) {
+ $format = '_input_';
+ }
+
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 adodb_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 +521,4 @@
{
return $this->Format( adodb_mktime(), $field, $object, $options['input_format']);
}
-}
\ No newline at end of file
+}
Event Timeline
Log In to Comment