1
0
mirror of https://github.com/oceanprotocol/commons.git synced 2023-03-15 18:03:00 +01:00

use hidden input to collect files array

This commit is contained in:
Matthias Kretschmann 2019-02-13 12:30:05 +01:00
parent f8405c8e5a
commit 7d3e123bf1
Signed by: m
GPG Key ID: 606EEEF3C479A91F
2 changed files with 18 additions and 5 deletions

View File

@ -9,7 +9,9 @@ import styles from './index.module.scss'
interface FilesProps {
files: string[]
placeholder: string
help: string
help?: string
name: string
onChange: any
// resetForm: any
}
@ -40,11 +42,20 @@ export default class Files extends PureComponent<FilesProps, FilesStates> {
public render() {
const { isFormShown } = this.state
const { files, help, placeholder } = this.props
const { files, help, placeholder, name, onChange } = this.props
return (
<>
<Help>{help}</Help>
{help && <Help>{help}</Help>}
{/* Use hidden input to collect files */}
<input
type="hidden"
name={name}
value={files}
onChange={onChange}
/>
<div className={styles.newItems}>
{files.length > 0 && (
<TransitionGroup

View File

@ -67,8 +67,10 @@ class Publish extends Component<{}, PublishState> {
</Label>
<Files
placeholder={value.placeholder}
name={value.name}
help={value.help}
files={this.state.files}
onChange={onChange}
/>
</Row>
)
@ -95,7 +97,7 @@ class Publish extends Component<{}, PublishState> {
event: ChangeEvent<HTMLInputElement> | ChangeEvent<HTMLSelectElement>
) => {
this.setState({
[event.target.name]: event.target.value
[event.currentTarget.name]: event.currentTarget.value
})
}
@ -103,7 +105,7 @@ class Publish extends Component<{}, PublishState> {
event: ChangeEvent<HTMLInputElement> | ChangeEvent<HTMLSelectElement>
) => {
this.setState({
[event.target.name]: [event.target.value]
[event.currentTarget.name]: [event.currentTarget.value]
})
}