-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[bootstrap-4] File uploads result in error ".file should match format "data-url"" #2095
Comments
Is this issue due to Bootstrap or Something to do with the react-jsonschema wrapper ? |
Yeah, this appears to be a problem with the bootstrap-4 theme. Seems like the form value is incorrectly being set to the file path, instead of the data url representation of the file: @anikethsaha @Xtremilicious is this something you might be able to look into? |
Are there any workarounds? |
@Hasenn I worked around it using this: I first created a widget in my repo called BootstrapFileWidget and reference the FileWidget from core:
Then i popped that into the widgets
Then, made sure my file was using that widget:
Not the cleanest workaround, but it got me up in running in a few minutes |
@tjuravich Nice solution but what happens when you need more than two or three file upload fields ? |
Still not the most elegant, but something like this:
|
Super small update to @tjuravich great solution :)
To have label like in bootstrap theme |
@tjuravich / @CKGrafico would you like to make a PR that fixes the bootstrap 4 file widget? 🙏 |
Let'ts wait to the original author @tjuravich if not, ping me. |
Here's another workaround which monkey-patches the library, without requiring you to do anything special in
The root cause of the bug is an incomplete implementation of FileWidget in the theme, which simply wraps around the text input. It doesn't work because obtaining data urls for the uploaded files requires some extra javascript functions, which are present in the core FileWidget. |
I think an easier way to do this would be just to override FileWidget in https://react-jsonschema-form.readthedocs.io/en/latest/advanced-customization/custom-widgets-fields/#customizing-the-default-fields-and-widgets? |
This bug is almost 1 year old and still not fixed - why? |
lol bugs don't fix themselves, someone has to fix it |
This thread has identified the root cause (thanks peterkelly), so I was hoping some of the maintainers would fix it. I am unfortunately not a React expert. |
Also see #2418 for more context |
Fixes rjsf-team#2095 by making `FileWidget` use the `BaseInputTemplate` for rendering the file input - Updated `@rjsf/utils` to fix two small bugs found while fixing the issue: - `dataURItoBlob()` was updated to deal with parsing errors in `atob()` with malformed URL and to decode the name to a human-readable string - Added additional tests to verify the fixes - `replaceStringParameters()` was updated to split using a regex to deal with situations where the params themselves contain replaceable character identifiers - Added an additional test to verify the bug was fixed - Updated `@rjsf/core` to switch `FileWidget` so that it uses the `BaseInputTemplate` to render the input, passing a new `onChangeOverride` function to deal with file events - Updated `BaseInputTemplate` to favor `onChangeOverride` rather than the default `onChange` handler it builds - Updated the `BaseInputTemplate` in all of the themes to also favor `onChangeOverride` if specified over the default `onChange` handler - Updated the snapshots in all themes to reflect the improved `FileWidget` use of `BaseInputTemplate` in all themes - Updated `@rjsf/bootstrap-4` to delete the `FileWidget` in favor of the improved `core` one - Updated `@rjsf/material-ui` and `@rjsf/mui` to have the `BaseInputTemplate` support the automatic `shrink` of the label when the `type` of the input is `date`, `datetime-local` and `file` - Also removed the `DateWidget` and `DateTimeWidget` in both themes since they were only providing the `shrink` behavior which is now encapsulated in `BaseInputTemplate` - Updated the `CHANGELOG.md` file accordingly
Fixes rjsf-team#2095 by making `FileWidget` use the `BaseInputTemplate` for rendering the file input - Updated `@rjsf/utils` to fix two small bugs found while fixing the issue: - `dataURItoBlob()` was updated to deal with parsing errors in `atob()` with malformed URL and to decode the name to a human-readable string - Added additional tests to verify the fixes - `replaceStringParameters()` was updated to split using a regex to deal with situations where the params themselves contain replaceable character identifiers - Added an additional test to verify the bug was fixed - Updated `@rjsf/core` to switch `FileWidget` so that it uses the `BaseInputTemplate` to render the input, passing a new `onChangeOverride` function to deal with file events - Updated `BaseInputTemplate` to favor `onChangeOverride` rather than the default `onChange` handler it builds - Updated the `BaseInputTemplate` in all of the themes to also favor `onChangeOverride` if specified over the default `onChange` handler - Updated the snapshots in all themes to reflect the improved `FileWidget` use of `BaseInputTemplate` in all themes - Updated `@rjsf/bootstrap-4` to delete the `FileWidget` in favor of the improved `core` one - Updated `@rjsf/material-ui` and `@rjsf/mui` to have the `BaseInputTemplate` support the automatic `shrink` of the label when the `type` of the input is `date`, `datetime-local` and `file` - Also removed the `DateWidget` and `DateTimeWidget` in both themes since they were only providing the `shrink` behavior which is now encapsulated in `BaseInputTemplate` - Updated the `CHANGELOG.md` file accordingly
Fixes rjsf-team#2095 by making `FileWidget` use the `BaseInputTemplate` for rendering the file input - Updated `@rjsf/utils` to fix two small bugs found while fixing the issue: - `dataURItoBlob()` was updated to deal with parsing errors in `atob()` with malformed URL and to decode the name to a human-readable string - Added additional tests to verify the fixes - `replaceStringParameters()` was updated to split using a regex to deal with situations where the params themselves contain replaceable character identifiers - Added an additional test to verify the bug was fixed - Updated `@rjsf/core` to switch `FileWidget` so that it uses the `BaseInputTemplate` to render the input, passing a new `onChangeOverride` function to deal with file events - Updated `BaseInputTemplate` to favor `onChangeOverride` rather than the default `onChange` handler it builds - Updated the `BaseInputTemplate` in all of the themes to also favor `onChangeOverride` if specified over the default `onChange` handler - Updated the snapshots in all themes to reflect the improved `FileWidget` use of `BaseInputTemplate` in all themes - Updated `@rjsf/bootstrap-4` to delete the `FileWidget` in favor of the improved `core` one - Updated `@rjsf/material-ui` and `@rjsf/mui` to have the `BaseInputTemplate` support the automatic `shrink` of the label when the `type` of the input is `date`, `datetime-local` and `file` - Also removed the `DateWidget` and `DateTimeWidget` in both themes since they were only providing the `shrink` behavior which is now encapsulated in `BaseInputTemplate` - Updated the `CHANGELOG.md` file accordingly
Fixes rjsf-team#2095 by making `FileWidget` use the `BaseInputTemplate` for rendering the file input - Updated `@rjsf/utils` to fix two small bugs found while fixing the issue: - `dataURItoBlob()` was updated to deal with parsing errors in `atob()` with malformed URL and to decode the name to a human-readable string - Added additional tests to verify the fixes - `replaceStringParameters()` was updated to split using a regex to deal with situations where the params themselves contain replaceable character identifiers - Added an additional test to verify the bug was fixed - Updated `@rjsf/core` to switch `FileWidget` so that it uses the `BaseInputTemplate` to render the input, passing a new `onChangeOverride` function to deal with file events - Updated `BaseInputTemplate` to favor `onChangeOverride` rather than the default `onChange` handler it builds - Updated the `BaseInputTemplate` in all of the themes to also favor `onChangeOverride` if specified over the default `onChange` handler - Updated the snapshots in all themes to reflect the improved `FileWidget` use of `BaseInputTemplate` in all themes - Updated `@rjsf/bootstrap-4` to delete the `FileWidget` in favor of the improved `core` one - Updated `@rjsf/material-ui` and `@rjsf/mui` to have the `BaseInputTemplate` support the automatic `shrink` of the label when the `type` of the input is `date`, `datetime-local` and `file` - Also removed the `DateWidget` and `DateTimeWidget` in both themes since they were only providing the `shrink` behavior which is now encapsulated in `BaseInputTemplate` - Updated the `CHANGELOG.md` file accordingly
Prerequisites
Description
Using the
bootstrap-4
theme, submitting a file triggers an error:Steps to Reproduce
Expected behavior
No errors are displayed.
Actual behavior
The following error is displayed:
Version
master
The text was updated successfully, but these errors were encountered: