Skip to content

Allow set condition attribute to be a function #1326

Closed
@Hyperkid123

Description

@Hyperkid123

Hi, before my question I want to thank you for your great library and your efforts to support and keep it updated.

I have a custom field array which its default values are set from other components based on some conditions. For example, in this sandbox, it is based on the text field if the value given is '3'.
It works fine if I want to set/replace the whole field array with a given value but how can I append to it?

in the example provided, the field array initial values are 1 -> one and 2 -> two or whatever user type, and I want to append the 3->three if I write 3 in the text field, how can I achieve this?

Code Exaple: codesandbox

Thanks

Originally posted by @Ali-Zmn in #1319

Required format:

The set attribute should be either an object or a function that returns desired object.

type set = object | (formApi: FormApi) => object

Function result should be extracted here and added to the state: https://github.com/data-driven-forms/react-forms/blob/master/packages/react-form-renderer/src/condition/condition.js#L48

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions