Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get anyOf field value on change? #835

Closed
1 task
varqasim opened this issue Feb 8, 2018 · 1 comment
Closed
1 task

How to get anyOf field value on change? #835

varqasim opened this issue Feb 8, 2018 · 1 comment

Comments

@varqasim
Copy link

varqasim commented Feb 8, 2018

Prerequisites

  • [ x] I have read the documentation;
  • In the case of a bug report, I understand that providing a SSCCE example is tremendously useful to the maintainers.

Description

I'm trying to populate an anyOf string input depending on another anyOf string input field. I want to detect the enum that has been chose in the anyOf #1 field so I would send an http request to fetch the data of the input that I have chose and to populate the #2 anyOf field.

The onChange method doesn't provide the value of the anyOf input field that have been changed. How would I do such thing?

Current Schema

const schema = {
            title: "Create new discount",
            type: "object",
            required: ["pool_id", "start", "end", "amount_off", "timeslot_id"],
            properties: {
                pool_id: {
                    type: "string",
                    title: "Pool",
                    anyOf: this.state.pools
                },
                start: {
                    type: "string",
                    title: "Start Date",
                    format: "date"
                },
                end: {
                    type: "string",
                    title: "End Date",
                    format: "date"
                },
                amount_off: {
                    type: "integer",
                    title: "Amount Off"
                },
            },
            dependencies: {
                pool_id: {
                    properties: {
                        timeslot_id: {
                            type: "string",
                            title: "Time Slot",
                            anyOf: this.state.timeslots
                        }
                    }
                }
            }
        }

Version

^1.0.0

@varqasim varqasim changed the title Detect anyOf field value on change How to get anyOf field value on change? Feb 8, 2018
@epicfaace
Copy link
Member

You might just need to call onChange and compare the entire new formData with the old formData you are storing in the state, to see which fields has been changed.

Closing this issue as it's been a while, but feel free to reopen it if you have any additional questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants