Code Monkey home page Code Monkey logo

wtforms-bootstrap5's People

Contributors

dependabot[bot] avatar fangpenlin avatar mxsasha avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

mxsasha

wtforms-bootstrap5's Issues

Is it possible to set a new input+value or add custom HTML to the form?

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.

render_kw ignored

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.