Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to generate other tags than "div" to the "Div" layout class. #880

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

fsbraun
Copy link

@fsbraun fsbraun commented May 6, 2019

The layout classes are a very versatile way of formatting forms. The Div layout class can be used to group elements and give them specific layouts (through the css_class parameter). Sometimes, however, it is helpful to have other elements, too, e.g. titles (h1 ... h6).

This pull requests adds a parameter tag to the Div class allowing the user to set the specific html tag required. If omitted it obviously falls back to the div tag.

This allows to keep HTML tags out of the HTML class making forms easier to internationalize

Div(HTML(_('My great form')), tag='h1')

The required adaptations are minimal and I have done them for all template sets.

@zoidyzoidzoid
Copy link
Contributor

I can understand why this might be useful, especially in the future with custom web components

Can you add some tests for this feature?

My only other concern is maybe we should change the name of this class from Div to Element or something, since it's no longer always a div? We can alias from Div to Element and keep div as the default tag potentially to make migrations easier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants