How to style or add a className to a Widget component? #282
-
Hello. What is the recommended way to style or add a className to a Widget component? For example, If i implement a Widget like this: |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
So the The best thing to do is define your own Widget class like so: import {
FieldHandler
} from "@reactivated";
const Widget = ({field}: {field: FieldHandler}) => {
// Exhaustive case statement, see linked source above.
} Note that I hesitate to add a |
Beta Was this translation helpful? Give feedback.
-
So is there no built in automatic way to do something like this that allows us to modify django forms on template like
the reason for this is to allow the template to automatically handle setting any restrictions to a form that were declared in the python forms class definition while also allowing me to add extra attributes via the template as well. Kinda following along with
thanks |
Beta Was this translation helpful? Give feedback.
So the
Widget
component is mainly designed for quick prototyping. From the source you can see it barely even handles theinput
tag:reactivated/packages/reactivated/src/forms/index.tsx
Line 464 in 6922107
The best thing to do is define your own Widget class like so:
Note that
FieldHandler
is automatically generated and will force you to handle all widgets. Including custom ones you may have defined.I hesitate to add a
className
prop toW…