Handle custom field date formatting

This commit is contained in:
Nathan Gray 2012-03-22 16:34:45 +00:00
parent 7bf2a9f575
commit 0c5c5ffb2c
2 changed files with 22 additions and 0 deletions

View File

@ -184,5 +184,14 @@ class etemplate_widget_customfields extends etemplate_widget_transformer
$this->setElementAttribute($form_name, 'customfields', $fields);
}
parent::beforeSendToClient($cname);
// Re-format date custom fields from Y-m-d
foreach($fields as $fname => $field)
{
if($field['type'] == 'date' && self::$request->content[self::$prefix.$fname])
{
self::$request->content[self::$prefix.$fname] = strtotime(self::$request->content[self::$prefix.$fname]);
}
}
}
}

View File

@ -261,6 +261,19 @@ var et2_customfields_list = et2_baseWidget.extend([et2_IDetachedDOM], {
// Make sure widget is created, and has the needed function
if(!this.widgets[field_name] || !this.widgets[field_name].set_value) continue;
var value = _value[this.prefix + field_name] ? _value[this.prefix + field_name] : null;
switch(this.options.customfields[field_name].type)
{
case 'date':
// Date custom fields are always in Y-m-d, which seldom matches user's preference
// which fails when sent to date widget. This is only used for nm rows, when possible
// this is fixed server side
if(value && isNaN(value))
{
value = jQuery.datepicker.parseDate("yy-mm-dd",value);
}
break;
}
this.widgets[field_name].set_value(value);
}
},