Re: Make tag name a variable in form templates

2020-07-23 Thread Carlton Gibson
I’m not sure I’m quite following your issue. At least to begin, can’t you just provide a custom base template, that accepts whatever parameters you want? Maybe there’s a case for adjusting the existing templates, but I’d imagine making that decision based on code in play. (“Look, I’ve built this,

Re: Make tag name a variable in form templates

2020-07-23 Thread '1337 Shadow Hacker' via Django developers (Contributions to Django itself)
Sent with [ProtonMail](https://protonmail.com) Secure Email. ‐‐‐ Original Message ‐‐‐ Le jeudi, juillet 23, 2020 6:53 PM, Adam Johnson a écrit : >> do you think it is better to create a widget class per custom element >> instead of just switching the template_name variable or just setti

Re: Make tag name a variable in form templates

2020-07-23 Thread Adam Johnson
> > do you think it is better to create a widget class per custom element > instead of just switching the template_name variable or just setting the > tag name like any attr ? I'd imagine so. This way you can make required attributes their own arguments to __init__, and any other customization yo

Re: Make tag name a variable in form templates

2020-07-23 Thread '1337 Shadow Hacker' via Django developers (Contributions to Django itself)
The type attribute might not be relevant to most custom elements, but they don't matter: if they are not supported then they will not be used. Thank you for your interesting suggestion, do you think it is better to create a widget class per custom element instead of just switching the template_n

Re: Make tag name a variable in form templates

2020-07-23 Thread Adam Johnson
I'm not sure I have an opinion on adding such a variable. It seems reasonable but I haven't seen much use of web components yet. I'm also not sure if e.g. the 'type' attribute is relevant if using a custom web component. But afaict you can change the tag already by overriding render() to replace i

Make tag name a variable in form templates

2020-07-23 Thread '1337 Shadow Hacker' via Django developers (Contributions to Django itself)
Hello Currently, we can set attributes on widgets during runtime but the input tag name is hardcoded: https://github.com/django/django/blob/master/django/forms/templates/django/forms/widgets/input.html Which means that you currently have to copy the input.html template for every web component.