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 form submit attributes (like formaction) to buttons #177

Open
ralokt opened this issue Oct 3, 2019 · 4 comments
Open

Add form submit attributes (like formaction) to buttons #177

ralokt opened this issue Oct 3, 2019 · 4 comments
Assignees

Comments

@ralokt
Copy link

ralokt commented Oct 3, 2019

See also: https://caniuse.com/#feat=form-submit-attributes

This would be awesome considering that form elements are not allowed to be nested. For constructing a formset with some buttons that do something with individual objects (move up/down, delete, ...) there are currently no good options.

  • Making the layout so that the forms aren't nested is a pain and shouldn't be necessary.
  • Detecting that we actually want to do something completely different than edit the entire formset on the server is hacky.
  • The best option by far of course is to just write the button element by hand instead of using the bootstrap_button tag. But it would still be nice not to have to do that.

If this is considered a worthwhile addition, I'm prepared to implement it.

@dyve
Copy link
Member

dyve commented Apr 22, 2020

Adding actions and maybe other attributes to buttons would be cool.

I'm also thinking of simplifying the widgets to templates, or perhaps dropping button support entirely, since it's often easier to just code the buttons manually.

Feel free to discuss a solution or even to submit a PR.

@ralokt
Copy link
Author

ralokt commented Apr 24, 2020

I already made #178 back then! It's not a very inspired solution, though, just more parameters for buttons.

Buttons are handled differently from fields in forms.py right now - fields take attributes as **kwargs, so adding new attributes to them is much easier. Perhaps it would be possible to refactor buttons to make them work in a similar way?

I did something similar for django-bootstrap3 back in the day: My old PR

In this PR, I also make using data attributes possible by converting attributes starting with data_ (and only those, for maximum backwards-compatibility) by substituting dashes for underscores.

Supporting data attributes would probably be a good idea anyway?

In any case, I think that making buttons less restrictive would be awesome and better than dropping support for them - less restrictions to work around would also mean that they are easier to use.

Let me know what you think, I'd definitely consider doing what I just suggested if you agree that it's a good idea (although unfortunately, to be completely honest, I can't really promise anything - many small jobs that all need to be done from home with few boundaries might make that difficult).

@dyve
Copy link
Member

dyve commented May 1, 2021

I came across this same problem in django-bootstrap5. Buttons need more options. Thanks for your patience on this.

@dyve
Copy link
Member

dyve commented May 3, 2021

I think this is what you mean (in django-bootstrap5):
zostera/django-bootstrap5#79

Note that this does not cover data attributes, we'll cover that in a separate issue.

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

No branches or pull requests

2 participants