admin on rest send extra params to rest call

后端 未结 1 841
刺人心
刺人心 2021-01-22 09:48

i have upload button inside create form, on button click handler i will upload image to cloud and on upload success i get image url. i need to pass this image url to rest api. t

相关标签:
1条回答
  • 2021-01-22 10:01

    You'll have to implement a custom input for that.

    Something like (haven't tested it):

    class UploadPictureInput extends Component {
        handleClick = () => {
            cloudinary.openUploadWidget({
                cloud_name: 'demo',
                upload_preset: 'sh3432',
                cropping: 'server'
            }, (error, result) => {
                this.props.input.onChange(result);
            });
        }
    
        render() {
            return (
                <FlatButton
                    style={styles.button}
                    label="Upload Image"
                    primary
                    onClick={this.handleClick}
                />
            );
        }
    }
    

    And use this input in your form.

    0 讨论(0)
提交回复
热议问题