My hot take for today is that I like vanilla JavaScript more than Django formsets.
-
Tim Schillingreplied to Carlton Gibson 🇪🇺 last edited by
@carlton @mahryekuh weird, I should have a better relationship with them then
-
Carlton Gibson 🇪🇺replied to Tim Schilling last edited by
@CodenameTim @mahryekuh They're just a list of forms, asking you to love them 🥰
-
Marijke Luttekesreplied to Carlton Gibson 🇪🇺 last edited by [email protected]
@carlton @CodenameTim Is this your inner Django user speaking, or your inner ex-Fellow?
-
Carlton Gibson 🇪🇺replied to Marijke Luttekes last edited by [email protected]
@mahryekuh @CodenameTim Ha! Good! That's a stonking question!
So, on the record, I love formsets, I use them all the time — ANY time I multiple forms to handle in a view. I do horrible things like create custom formsets to handle multiple form types when that's needed, and I think they offer a clean API (to the client, not necessarily the writer) that hides a lot of rubbish.
1/2
-
Carlton Gibson 🇪🇺replied to Carlton Gibson 🇪🇺 last edited by
@mahryekuh @CodenameTim Having said that, I acknowledge there's an amount of cruft in there, and a massive lack of decent How-Tos, so Formsets are also on the list for my "Modern Django Forms" piece, when I actually get to write that. 🫠
2/2
-
Marijke Luttekesreplied to Carlton Gibson 🇪🇺 last edited by
> "I do horrible things like create custom formsets to handle multiple form types when that's needed"
Check.
That said, I have also been tempted to write some articles about the form sets, but tell that to my backlog.
The "Delete" checkbox is one sore point out of the box, as it gives little indication of which row is up for deletion. Form sets without JavaScript are not great.
-
Carlton Gibson 🇪🇺replied to Marijke Luttekes last edited by
@mahryekuh @CodenameTim With you almost to the end there
-
Carlton Gibson 🇪🇺replied to Marijke Luttekes last edited by
> The "Delete" checkbox is one sore point out of the box, as it gives little indication of which row is up for deletion.
The default markup could be improved right?
-
Marijke Luttekesreplied to Carlton Gibson 🇪🇺 last edited by
@carlton Yes, but it will need JavaScript.
For example, the delete label should refer to the entity it is deleting.
In an ideal situation, you would visibly remove the row from the list of forms and have the "delete" checkbox input replaced with a hidden value to please the back-end.
For an app primarily geared towards screen reader users, we also discussed adding rows in a `<dialog>` rather than on the main page.
-
Marijke Luttekesreplied to Carlton Gibson 🇪🇺 last edited by
@carlton @CodenameTim It's OK. The current implementation works without JavaScript, and you can progressively enhance it if you want to. Then everyone is happy. 🥳
-
Carlton Gibson 🇪🇺replied to Marijke Luttekes last edited by
@mahryekuh I think that would make an interesting discussion, especially thinking about progressive enhancement there. Zero, Some, More JS versions, say. 🧐
-
Marijke Luttekesreplied to Carlton Gibson 🇪🇺 last edited by