Skip to content

Commit

Permalink
FIO-7184 Fixed showing incorrect value for DateTime and Time componen… (
Browse files Browse the repository at this point in the history
#5393)

* FIO-7184 Fixed showing incorrect value for DateTime and Time components with multiple value enabled inside of the DataTable

* FIO-7184 Added code for a missing condition
  • Loading branch information
antonSoftensity authored Nov 23, 2023
1 parent b564156 commit 492cdfa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/components/datetime/DateTime.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,15 @@ export default class DateTimeComponent extends Input {
format += format.match(/z$/) ? '' : ' z';
const timezone = this.timezone;
if (value && !this.attached && timezone) {
if (Array.isArray(value) && this.component.multiple) {
return value.map(item => _.trim(FormioUtils.momentDate(item, format, timezone).format(format))).join(', ');
}
return _.trim(FormioUtils.momentDate(value, format, timezone).format(format));
}

if (Array.isArray(value) && this.component.multiple) {
return value.map(item => _.trim(moment(item).format(format))).join(', ');
}
return (value ? _.trim(moment(value).format(format)) : value) || '';
}
}
3 changes: 3 additions & 0 deletions src/components/time/Time.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ export default class TimeComponent extends TextFieldComponent {
}

getValueAsString(value) {
if (Array.isArray(value) && this.component.multiple) {
return value.map(item => moment(item, this.component.dataFormat).format(this.component.format)).join(', ');
}
return (value ? moment(value, this.component.dataFormat).format(this.component.format) : value) || '';
}

Expand Down

0 comments on commit 492cdfa

Please sign in to comment.