carltongibson / neapolitan

Quick CRUD views for Django
https://noumenal.es/neapolitan/
MIT License
413 stars 30 forks source link

Provide a way to modify CSS classes on form & elements #17

Open jonnyhoff opened 1 year ago

jonnyhoff commented 1 year ago

Please provide a way to modify the CSS classes of the form & elements

carltongibson commented 1 year ago

Hi @jonnyhoff.

CRUDView allows you to specify a form_class:

https://github.com/carltongibson/neapolitan/blob/d80a4c7068ae2d2abb9c655ac3889e8787531680/src/neapolitan/views.py#L85

... and if you need more control, provides both the get_form_class() and get_form() hooks that you can override:

https://github.com/carltongibson/neapolitan/blob/d80a4c7068ae2d2abb9c655ac3889e8787531680/src/neapolitan/views.py#L156-L177

Beyond that, you'd customise the form templates as normal.

Anything you're missing there?

jonnyhoff commented 1 year ago

Hi @carltongibson , Thanks for the prompt response. Do you have examples of how to use the above or links to docs?

carltongibson commented 1 year ago

Not yet, but I'll use this ticket to track that. Thanks!

It's no different from what you'd do with Django's views if that helps. (See the docs I linked)

carltongibson commented 1 year ago

Also refs #8, which is about providing a Tailwind plugin to style the default Django form markup, in a similar way to the official prose Tailwind plugin.