rjsf-team / react-jsonschema-form

A React component for building Web forms from JSON Schema.
https://rjsf-team.github.io/react-jsonschema-form/
Apache License 2.0
13.85k stars 2.17k forks source link

setting options via ui:widget object is no longer supported, use ui:options instead #4084

Open koh-osug opened 4 months ago

koh-osug commented 4 months ago

Prerequisites

What theme are you using?

other

What is your question?

It seems I have an issue with the migration from ui:widget to ui:options. How can this be migrated? I have looked into the migration guide but could not find any information. I get this error:

setting options via ui:widget object is no longer supported, use ui:options instead

I have several locations where I use "hidden" with the ui:widget like this:

let orderModalUISchema = {
  orderId: {"ui:widget": 'hidden'},
  status: {"ui:widget": 'hidden'},
};

I also use the widget for custom components like this which seem to be responsible for the issue:

"ui:widget": connect(mapStateToProps)((props) => {
      const onChangeSubscriberId = (event) => {
        props.onChange(event.target.value);
      };

      return (
          <select disabled={disabled} onChange={onChangeSubscriberId} value={props.value} id="root_subscriberId"
                  className='form-control' required>
            <option key="empty" value=""></option>
            {props.subscribers.map(subscriber => (
                <option key={subscriber.id} value={subscriber.id}>
                  {subscriber.id}____{subscriber.name}
                </option>
            ))}
          </select>
      );
    }),

Interesting is, when I wrap this with a withRouter the error is not happening.

I'm using Bootstrap 3.

heath-freenome commented 4 months ago

Does using the following work?:

let orderModalUISchema = {
  orderId: {"ui:options": { 'widget': 'hidden'} },
  status: {"ui:options": { 'widget': 'hidden'} },
};
koh-osug commented 4 months ago

@heath-freenome This works for the simple fields. Thanks. For the created widget prefixing with the "ui:options" does not work.

heath-freenome commented 4 months ago

@koh-osug If you were to take your custom widget and register it on the form with a unique key, then perhaps you will be able to refer to it by name instead? See the documentation on how to do this