starlette-admin icon indicating copy to clipboard operation
starlette-admin copied to clipboard

Enhancement: Add `html_params` class attribute to `BaseField`

Open hasansezertasan opened this issue 6 months ago • 1 comments

Is your feature request related to a problem? Please describe. As HTMX rises, we see many new libraries based on HTML attributes like AlpineJS and Hyperscript.

I am using HTMX, AlpineJS, and Hyperscript in my projects now and these libraries mostly rely on HTML attributes, so to use them properly I have to override each Field and add html_params class attribute.

Describe the solution you'd like I don't know if I'm asking too much but what about adding that html_params attribute to the BaseField class and updating input_params methods?

Additional context I believe in the end, this feature will be in demand.

hasansezertasan avatar Feb 21 '24 04:02 hasansezertasan

WDYT about this @jowilf?

I did some work on it, you can find it at hasansezertasan/starlette-admin/tree/html_params. I've been hesitating about opening PR for a while. I would be very happy if you review it and I would like to open PR if you deem it appropriate.

Also, if I pass the hyperscript attributes ({"_":"statement"}), the html_params function turns the underscores into dashes, so it's still not working for the hyperscript library.

https://github.com/jowilf/starlette-admin/blob/1c51b60c59bae5cb9cb964c0ed1da85a6b75ff9c/starlette_admin/helpers.py#L74-L84

Take a look at the hyperscript usage: ///_hyperscript

hasansezertasan avatar Feb 22 '24 16:02 hasansezertasan