You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I’m trying to create what should be a simple form, with some requirements. The form should have a dropdown with two options in it. Changing the options should load different schemas underneath – both schemas should have a shared field, with the same name, that is set a different value depending on the option picked; one schema should have an additional string field, that is required and should match a pattern.
I have tried to implement this in two ways – using a one of/anyOf and using an enum with dependencies. The behaviour of both implementations is close but not quite right to what I need.
Changing the option updates the shared value. When the second option is chosen, a unique field is shown that is pattern validated and is also marked required.
Actual behavior
With one of (or anyOf), changing the option does update the shared value. When the second option is chosen, the unique field is shown, but validated only against it being required – the pattern is ignored. Changing back to option one, the unique field formData is removed.
With enums and dependencies, changing the option does not update the shared value. This could be linked to #1558 – the value is not resetting to default. If option two is selected, the unique field is shown, and the required / pattern matching works correctly. Changing back to option one, the unique field formData is not removed.
I had a look through the source and from the implementation of mergeDefaultsWithFormData it looks like if formData is present for a field when changing schema, it’s supposed to override the default, so my section implementation may be failing by design.
Perhaps I’m using the schema wrong and there is a third way... suggestions appreciated. Thanks!
Version
Both 1.8.1 and 2.0.1
The text was updated successfully, but these errors were encountered:
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please leave a comment if this is still an issue for you. Thank you.
Prerequisites
Description
I’m trying to create what should be a simple form, with some requirements. The form should have a dropdown with two options in it. Changing the options should load different schemas underneath – both schemas should have a shared field, with the same name, that is set a different value depending on the option picked; one schema should have an additional string field, that is required and should match a pattern.
I have tried to implement this in two ways – using a one of/anyOf and using an enum with dependencies. The behaviour of both implementations is close but not quite right to what I need.
Steps to Reproduce
My attempts are here:
With one of (or anyOf): https://tinyurl.com/y7bt3pqr
With enums and dependencies: https://tinyurl.com/y9qpjbx6
Expected behavior
Changing the option updates the shared value. When the second option is chosen, a unique field is shown that is pattern validated and is also marked required.
Actual behavior
With one of (or anyOf), changing the option does update the shared value. When the second option is chosen, the unique field is shown, but validated only against it being required – the pattern is ignored. Changing back to option one, the unique field formData is removed.
With enums and dependencies, changing the option does not update the shared value. This could be linked to #1558 – the value is not resetting to default. If option two is selected, the unique field is shown, and the required / pattern matching works correctly. Changing back to option one, the unique field formData is not removed.
I had a look through the source and from the implementation of mergeDefaultsWithFormData it looks like if formData is present for a field when changing schema, it’s supposed to override the default, so my section implementation may be failing by design.
Perhaps I’m using the schema wrong and there is a third way... suggestions appreciated. Thanks!
Version
Both 1.8.1 and 2.0.1
The text was updated successfully, but these errors were encountered: