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 compute using nested fields? #22

Open
nareshbhatia opened this issue Aug 8, 2018 · 1 comment
Open

How to compute using nested fields? #22

nareshbhatia opened this issue Aug 8, 2018 · 1 comment

Comments

@nareshbhatia
Copy link

nareshbhatia commented Aug 8, 2018

Are you submitting a bug report or a feature request?

Feature request

What is the current behavior?

The example shows computations using top level fields.

What is the expected behavior?

Can you please provide an example that computes using nested fields? For example, I need to compute a date object (startTime), based on date and time fields (datePart and timePart) that are nested in a meeting object.

<Field
    name="meeting.datePart"
    component={TextField}
    type="text"
    label="Start Date"
/>
<Field
    name="meeting.timePart"
    component={TextField}
    type="text"
    label="Time"
/>
<Field
    name="meeting.startTime"
    component={TextField}
    type="text"
    label="Start Time"
/>
@iloveip
Copy link

iloveip commented Feb 19, 2020

There is an example in the doc for nested fields:

{
    field: /\.timeFrom/, // when a deeper field matching this pattern changes...
    updates: (value, name, allValues) => {
      const toField = name.replace('timeFrom', 'timeTo')
      const toValue = getIn(allValues, toField)
      if (toValue && value > toValue) {
        return {
          [toField]: value
        }
      }

      return {}
    }
  }

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

No branches or pull requests

2 participants