@@ -3,7 +3,7 @@ import { Formio } from '../../Formio';
33import ListComponent from '../_classes/list/ListComponent' ;
44import Input from '../_classes/input/Input' ;
55import Form from '../../Form' ;
6- import { getRandomComponentId , boolValue , isPromise , componentValueTypes , getComponentSavedTypes } from '../../utils/utils' ;
6+ import { getRandomComponentId , boolValue , isPromise , componentValueTypes , getComponentSavedTypes , unescapeHTML } from '../../utils/utils' ;
77import Choices from '../../utils/ChoicesWrapper' ;
88
99export default class SelectComponent extends ListComponent {
@@ -1221,10 +1221,10 @@ export default class SelectComponent extends ListComponent {
12211221 return added ;
12221222 }
12231223
1224- getValueAsString ( data ) {
1224+ getValueAsString ( data , options ) {
12251225 return ( this . component . multiple && Array . isArray ( data ) )
1226- ? data . map ( this . asString . bind ( this ) ) . join ( ', ' )
1227- : this . asString ( data ) ;
1226+ ? data . map ( ( v ) => this . asString ( v , options ) ) . join ( ', ' )
1227+ : this . asString ( data , options ) ;
12281228 }
12291229
12301230 getValue ( ) {
@@ -1636,7 +1636,7 @@ export default class SelectComponent extends ListComponent {
16361636 ) ;
16371637 }
16381638
1639- asString ( value ) {
1639+ asString ( value , options = { } ) {
16401640 value = value ?? this . getValue ( ) ;
16411641 //need to convert values to strings to be able to compare values with available options that are strings
16421642 const convertToString = ( data , valueProperty ) => {
@@ -1697,13 +1697,20 @@ export default class SelectComponent extends ListComponent {
16971697 return value ;
16981698 }
16991699
1700+ const getTemplateValue = ( v ) => {
1701+ const itemTemplate = this . itemTemplate ( v ) ;
1702+ return options . csv && itemTemplate
1703+ ? unescapeHTML ( itemTemplate )
1704+ : itemTemplate ;
1705+ } ;
1706+
17001707 if ( Array . isArray ( value ) ) {
17011708 const items = [ ] ;
1702- value . forEach ( item => items . push ( this . itemTemplate ( item ) ) ) ;
1709+ value . forEach ( item => items . push ( getTemplateValue ( item ) ) ) ;
17031710 if ( this . component . dataSrc === 'resource' && items . length > 0 ) {
17041711 return items . join ( ', ' ) ;
17051712 }
1706- else if ( items . length > 0 ) {
1713+ else if ( items . length > 0 ) {
17071714 return items . join ( '<br />' ) ;
17081715 }
17091716 else {
@@ -1716,7 +1723,7 @@ export default class SelectComponent extends ListComponent {
17161723 }
17171724
17181725 return ! _ . isNil ( value )
1719- ? this . itemTemplate ( value )
1726+ ? getTemplateValue ( value )
17201727 : '-' ;
17211728 }
17221729
0 commit comments