Skip to content

Creating a dependency for an element marked as "required" does not remove the element from the array of required fields #172

Open
@ssmithereens

Description

@ssmithereens

If you create a form with elements newInput1 and newInput2 (both with input type short answer) and mark newInput2 as a required field, the resulting schema is:

{ type: 'object', properties: { newInput1: { title: 'New Input 1', type: 'string' }, newInput2: { title: 'New Input 2', type: 'string' } }, dependencies: {}, required: [ 'newInput2' ] }

If you then create a dependency for newInput1 so that if it shows newInput2 if newInput1 has any value, the following schema is produced:

{ type: 'object', properties: { newInput1: { title: 'New Input 1', type: 'string' } }, dependencies: { newInput1: { properties: { newInput2: { title: 'New Input 2', type: 'string' } }, required: [ 'newInput2' ] } }, required: [ 'newInput2' ] }

newInput2 is incorrectly still set as a required field in the parent required fields array, which means that the form can't be successfully submitted by the user. The validation error '.newInput2 is a required property' is triggered, even though newInput2 is only conditionally shown if newInput1 has a value.

Expected behaviour: newInput2 should be removed from the parent required fields array, since it is a dependent field.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions