helloflask / bootstrap-flask

Bootstrap 4 & 5 helper for your Flask projects.
https://bootstrap-flask.readthedocs.io
Other
1.12k stars 190 forks source link

no label for radio buttons in form of type 'inline' #237

Closed bbbart closed 2 years ago

bbbart commented 2 years ago

When you render a form with form_type="inline" the form labels get the class visually-hidden assigned to them.

I was wondering what the rationale behind this is? Is this a best practice of some sort?

Perhaps I'm not using the form_type correctly. What I'm looking for is a way to have my radio buttons rendered horizontally.

greyli commented 2 years ago

Can you provide more details on this issue? For example, the template, Bootstrap version, the screenshot of the current render result, and your expected result.

If the label for the radio button is missing, it seems to be a bug.

For ref: https://getbootstrap.com/docs/5.0/forms/layout/#inline-forms

greyli commented 2 years ago

I just tested this locally, and the rendering result of the inlineRadioField is correct.

image

If you want to make the radio buttons rendered horizontally, you may need to manually write the Bootstrap code.

bbbart commented 2 years ago

Hi!

So sorry for my late reply and thank you for following this one up.

I'm a bit confused now, as I was referring to

https://github.com/helloflask/bootstrap-flask/blob/5d013090f3f941cb18bddb6fa222c1279f923244/flask_bootstrap/templates/bootstrap5/form.html#L83-L88

where one can see that inline RadioFields explicitly get a visually hidden label, no?

You are right that manually writing HTML instead of relying on the provided macros is a way out here.

greyli commented 2 years ago

The code should be correct, when the form type is inline, the radio field label should be hidden, and only the item labels were displayed.

https://getbootstrap.com/docs/5.0/forms/layout/#inline-forms

You may want to set the form type to horizontal.

bbbart commented 2 years ago

Yes, I also believe the code is according to the bootstrap documentation. I think I need to figure out the rationale behind that, then.

Thank you for your efforts!