newforms icon indicating copy to clipboard operation
newforms copied to clipboard

How to bind custom widget to auto validation?

Open kevzettler opened this issue 9 years ago • 2 comments

Hi I'm building some custom widgets and they are not being bound to the auto validation. Are there any examples of this?

kevzettler avatar Nov 12 '14 23:11 kevzettler

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.

insin avatar Nov 13 '14 00:11 insin

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?

kevzettler avatar Nov 17 '14 21:11 kevzettler