bootstrap-flask
bootstrap-flask copied to clipboard
Improved form rendering
Updated form rendering to properly use bootstrap v.4, it now also works with nested forms and custom form elements. Basically, I just went to bootstrap/components/forms, and implemented the rendering based on the examples there. I've made the interface a lot more flexible, but and if if you think its needed yet, I can make it backwards compatible
If you approve, I'll attempt to make some documentation
Since you can't easily override macros, I've wrapped them all in a block that you can then extend, the alternative would be this. There's also a block that you can extend if you need to provide rendering of custom form elements
Pull Request Test Coverage Report for Build 37
- 3 of 4 (75.0%) changed or added relevant lines in 1 file are covered.
- 1 unchanged line in 1 file lost coverage.
- Overall coverage decreased (-1.7%) to 86.538%
Changes Missing Coverage | Covered Lines | Changed/Added Lines | % |
---|---|---|---|
flask_bootstrap/init.py | 3 | 4 | 75.0% |
<!-- | Total: | 3 | 4 |
Files with Coverage Reduction | New Missed Lines | % |
---|---|---|
flask_bootstrap/init.py | 1 | 86.54% |
<!-- | Total: | 1 |
Totals | |
---|---|
Change from base Build 28: | -1.7% |
Covered Lines: | 45 |
Relevant Lines: | 52 |
💛 - Coveralls
I'm still not really satisfied with how widgets, especially TableWidget
s, are rendered inside ListWidget
s, I'd like the label & help text to be in a top row if possible
Thanks very much! I will review your code as soon as I have free time.
LGTM! Just go ahead to update the docs.
I've made the interface a lot more flexible, but and if you think its needed yet, I can make it backward compatible.
Does this PR break something?
Does this PR break something?
I've changed the interface of the render_field
, render_form
macros and removed the form_errors
macro. I've also removed the bootstrap_is_hidden_field
jinja function, and replaced it with the is_hidden
test
IMO, it's a good idea to make it backward compatible.
I've tried documenting a little bit, but I'm unsure about the format. Should I:
- Make a seperate file, where I put information about all the methods, and how to customize the form rendering
- Only document the single
render_form
method
Or something in between those two?
I prefer to make a new file.
Can we just keep the old keyword arguments (i.e. action
, method
, extra_classes
etc)? Both in the code and the docs. These arguments were commonly used when people rendering a form.
If you feel like we should do that, then yes, easily. Which ones do you want to keep precisely, action
, method
, role
, enctype
, id
, novalidate
and extra_classes
?
@madsmtm We need to let user transfer easily from Flask—Bootstrap to this project, so I want to keep all of them.
Well, but I don't see a reason to update the code, since after I made it backwards compatible, they can, they don't need to do anything. But if you want it added to the docs, I'll be happy to do so, I'm out of time for today though
OK, you are right, just update the docs will be enough.