Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Show all options in an AnyOf or OneOf when printing #1348

Closed
nathfy opened this issue Jul 9, 2019 · 6 comments
Closed

Show all options in an AnyOf or OneOf when printing #1348

nathfy opened this issue Jul 9, 2019 · 6 comments

Comments

@nathfy
Copy link

nathfy commented Jul 9, 2019

Prerequisites

Description

We are using the project to show a web form as well as printing to pdf for paper use. For the printed version we would like to show all the options in a oneOf/anyOf section. As far as I can see this would mean overriding the MultiSchemaField.js (https://github.com/mozilla-services/react-jsonschema-form/blob/c5e8899701279a2ab1ac75551824ff24b8d187a4/src/components/fields/MultiSchemaField.js) field to show all the options passed to it.
Or maybe replace the Field template do it there.

See the OneOf and AnyOf on the playground, and then imagine that printed to pdf with all the options listed one under the other... https://mozilla-services.github.io/react-jsonschema-form/

Anyone got any pointers on how to sort it?

Steps to Reproduce

see description

Expected behavior

see description

Actual behavior

see description

Version

Latest

@epicfaace
Copy link
Member

@nathfy you should actually be able to override the SelectWidget because it is now used for OneOf/AnyOf since #1220.

@nathfy
Copy link
Author

nathfy commented Jul 10, 2019

@epicfaace thanks, so if I override the select dropdown as per https://codesandbox.io/embed/6wxv10mz2k can I then force all of the options to show at once? In the example above Person and Dog inputs need to show at the same time (for printing). Any pointers on how? Thanks.

@epicfaace
Copy link
Member

Hmm, I see what you're asking -- you want all the inputs to show at once, right? Right now we don't support that, unless you create your own custom field and then set OneOfField to the custom field. It may be good for react-jsonschema-form to have an option to show all of the oneOf options though, perhaps by a built-in field.

@nathfy
Copy link
Author

nathfy commented Aug 23, 2019

Thanks @epicfaace for the info - I tried to override the OneOfField as described with:

render() {
const customFields = {
      OneOfField: CustomOneOfField
    };
return (
<JsonSchemaForm
                schema={x.formJson}
                uiSchema={x.formJsonUiSchema}
                formData={x.formData}
                fields={customFields}
              />
);
}

But it isn't being picked up and used, the JsonSchemaForm is continuing to use the old OneOfField instead.

My custom OneOfField is attached, based on the existing:
https://github.com/mozilla-services/react-jsonschema-form/blob/master/src/components/fields/MultiSchemaField.js

Any pointers to what I am doing wrong to override it?
customOneOfField.zip

@epicfaace
Copy link
Member

@nathfy not sure, perhaps it has something to do with how you are importing CustomOneOfField. You are overriding it correctly; see this jsfiddle for an example. Maybe you could share more of your code as the issue probably lies there.

@stale
Copy link

stale bot commented Apr 15, 2022

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.

@stale stale bot added the wontfix label Apr 15, 2022
@stale stale bot closed this as completed May 1, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants