newforms
newforms copied to clipboard
How to bind custom widget to auto validation?
Hi I'm building some custom widgets and they are not being bound to the auto validation. Are there any examples of this?
An onChange
handler is always passed as a property of theattrs
object in the kwargs
object which is passed to a Widget's render(name, value, kwargs)
method. If you look at BoundField#asWidget
this is where the kwargs object is set up.
This onChange
handler needs to be hooked up to whichever form input you're generating.
You never see it being referenced in widgets.js
because it's already part of kwargs.attrs
.
Ok that helps a lot then once I have the widget bound to the onChange
and onBlur
how do I hook into the error state and render the inline validation methods?