react-jsonschema-form icon indicating copy to clipboard operation
react-jsonschema-form copied to clipboard

Move label gen from TexWidget to FieldTemplate for bootstrap4

Open newt10 opened this issue 3 years ago • 4 comments

Reasons for making this change

  1. The current code for FieldTemplate and TextWidget in bootstrap 4 is incompatible with the core package. This breaks the external facing API for customizing field template.
  2. According to the core package implementation and documents, FieldTemplate is responsible for layout of labels, description, errors and help while the input widget along with the state is to be managed by the Field Component themselves (and Widgets)
  3. If a user, uses custom field template with the bootstrap 4 form, the label is displayed multiple times, once by the custom field template (as intended in the API) and second time by the TextWidget (breaks from the core package convention)

This fixes the problem and updates the tests to catch any future regressions.

If this is related to existing tickets, include links to them as well. Use the syntax fixes #2007 (ex: fixes #123).

Checklist

  • [ ] I'm updating documentation
  • [x] I'm adding or updating code
    • [x] I've added and/or updated tests
    • [x] I've updated docs if needed
  • [ ] I'm adding a new feature
    • [ ] I've updated the playground with an example use of the feature

Since this is a bug fix, no docs need to be updated, docs already provide the correct information on how to use custom field templates.

I have updated all the tests

Test from Playground

Screen Shot 2021-09-01 at 2 14 25 PM

All tests passing

Screen Shot 2021-09-01 at 6 20 44 PM Screen Shot 2021-09-01 at 6 22 03 PM

newt10 avatar Sep 02 '21 01:09 newt10

@epicfaace , this fixes a core problem with bootstrap4 form referenced in the issue #2007. Let me know if you need anything from me to move this along.

newt10 avatar Sep 02 '21 01:09 newt10

Can also provide workarounds for overriding TitleField and DescriptionField by allowing users to provide custom FieldTemplate. This has been requested many time under #1687 , #2219

newt10 avatar Sep 03 '21 22:09 newt10

This would be a great add!

devo-wm avatar Sep 21 '21 15:09 devo-wm

@newt10 If you were to update these changes on top of the v5 beta, I would be willing to review/approve. Please NOTE that the TextWidget was refactored into the new BaseInputTemplate so you will have to move your code accordingly

heath-freenome avatar Aug 29 '22 17:08 heath-freenome