launchplatform / wtforms-bootstrap5 Goto Github PK
View Code? Open in Web Editor NEWSimple library for rendering WTForms in HTML as Bootstrap 5 form controls
License: MIT License
Simple library for rendering WTForms in HTML as Bootstrap 5 form controls
License: MIT License
Hey guys, thanks for the amazing library, some context for what I'm doing:
A CRUD with FastAPI, basically.
I managed to transform my SQLALchemy schemas to a form with wtforms-sqlalchemy, but the form wasn't fitting very well as I was using bootstrap and the form was very crude, so I'm using this lib to beautify the generated form.
I generate the form with:
from wtforms_sqlalchemy.orm import model_form
MyForm = model_form(MyClass)
form = MyForm()
then on my HTML I only do this, since it contains all <form>
in renderer:
{{
render_context
.form(action=request.url_for('update_myclass'))
.render(form)
}}
So far it's working, but I'm facing some struggles:
It would be amazing if I can create the submit button with the RenderContext, as wtforms sqlalchemy does not generate a submit button I need to create a parent class that has submitted option and inherit Form this class then reorder the fields then........ it's a workaround.
I can't manage to post my class ID/PK to be updated as well, if I were doing with pure HTML I would set a new hidden field with the ID, e.g: <input type="hidden" name="id" value="6">
I was thinking about something like:
{{
render_context
.form(action=request.url_for('update_myclass'))
.post_params(name="id", value"123"),
.add_submit_button(name="save, send, update, some text for button"),
.render(form)
}}
If this isn't the way or have another method of doing those two things I would love to hear, so far I was thinking of getting the generated HTML and injecting those fields I need, but this doesn't feel right tbh, I think it would be less ugly if I could inject something in the middle of the generated HTML of the renderer directly.
Is there any reason render_kw
is ignored during rendering? As the first example shows an EmailField
with placeholder cannot be created the way it used to. Would be nice if one could add classes or a "disabled" flag within the WTForm so you don't have to change those within the render context. Or is this not intended?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.