@@ -38,7 +38,7 @@ export function FormInput({label, help_text, error, inputRef, ...props}) {
3838 < div { ...wrapperProps } >
3939 < Label label = { label } required = { props . required } />
4040 < div className = { error ? "rjf-input-group has-error" : "rjf-input-group" } >
41- < input { ...props } />
41+ { props . children || < input { ...props } /> }
4242 { error && error . map ( ( error , i ) => < span className = "rjf-error-text" key = { i } > { error } </ span > ) }
4343 { help_text && < span className = "rjf-help-text" > { help_text } </ span > }
4444 </ div >
@@ -201,15 +201,17 @@ export class FormMultiSelectInput extends React.Component {
201201 < div className = "rjf-multiselect-field" >
202202 < FormInput
203203 label = { this . props . label }
204- type = "text"
205- value = { this . props . value . length ? this . props . value . length + ' selected' : 'Select...' }
206204 help_text = { this . props . help_text }
207205 error = { this . props . error }
208- onClick = { this . toggleOptions }
209- readOnly = { true }
210- inputRef = { this . input }
211- className = "rjf-multiselect-field-input"
212- />
206+ >
207+ < FormMultiSelectInputField
208+ inputRef = { this . input }
209+ onClick = { this . toggleOptions }
210+ value = { this . props . value }
211+ onChange = { this . handleChange }
212+ disabled = { this . props . readOnly }
213+ />
214+ </ FormInput >
213215 { this . state . showOptions &&
214216 < FormMultiSelectInputOptions
215217 options = { this . props . options }
@@ -227,6 +229,45 @@ export class FormMultiSelectInput extends React.Component {
227229 }
228230}
229231
232+ class FormMultiSelectInputField extends React . Component {
233+ handleRemove = ( e , index ) => {
234+ e . stopPropagation ( ) ;
235+
236+ // we create a fake event object for the onChange handler
237+ let event = {
238+ target : {
239+ value : this . props . value [ index ] ,
240+ checket : false
241+ }
242+ } ;
243+
244+ this . props . onChange ( event ) ;
245+ }
246+
247+ render ( ) {
248+ return (
249+ < div
250+ className = "rjf-multiselect-field-input"
251+ onClick = { this . props . onClick }
252+ ref = { this . props . inputRef }
253+ >
254+ {
255+ this . props . value . length ?
256+ this . props . value . map ( ( item , index ) => (
257+ < span className = "rjf-multiselect-field-input-item" key = { item + '_' + index } >
258+ < span > { item } </ span >
259+ { this . props . disabled || < button title = "Remove" type = "button" onClick = { ( e ) => this . handleRemove ( e , index ) } > ×</ button > }
260+ </ span >
261+ )
262+ )
263+ :
264+ < span className = "rjf-multiselect-field-input-placeholder" > Select...</ span >
265+ }
266+ </ div >
267+ ) ;
268+ }
269+ }
270+
230271class FormMultiSelectInputOptions extends React . Component {
231272 componentDidMount ( ) {
232273 document . addEventListener ( 'mousedown' , this . handleClickOutside ) ;
0 commit comments