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
…ts with multiple value enabled inside of the DataTable
  • Loading branch information
antonSoftensity committed Nov 3, 2023
1 parent 51f82ab commit 38dd9ff
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/components/datetime/DateTime.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@ 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));
}
return (value ? _.trim(moment(value).format(format)) : value) || '';
Expand Down
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 38dd9ff

Please sign in to comment.