Skip to content

[New Feature] Implementing setFieldValue #2099

@reabiliti

Description

@reabiliti

Prerequisites

Description

Hi folks, I didn't find ability to setup formData for multiple field. As I understand there is only ability to set current field. I would like to change formData with additional function which will take newFormData and path where I need to change data.
For example, I have object with fields:

{
  symptom: {
    title: "Condition",
    type: "object",
    required: [:id, :name],
    properties: {
      id: {
        type: "number",
        title: 'id'
      },
      name: {
        type: "string",
        title: 'name'
      }
    }
  }
}

And I've created my own widget, with will render select where I choose symptom, but value already includes id and name and I would like update symptom key with data { id: 1, name: 'Name' }

const SymptomWidget = props => {
  const onChangeSymptom = symptom => {
    const parsedSymptom = symptom ? JSON.parse(symptom) : null
    const id = pathOr('', ['0'], parsedSymptom)
    const name = pathOr('', ['1'], parsedSymptom)
    props.onChange({ id, name })
  }
  return <ConditionSelect onChange={onChangeSymptom} />
}

But I get this result: { symptom: id: { id: 1, name: 'Name' } }.

Version

2.4

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions