Put all widget initialization code in one function.

That way in can be called easily for dynamically added forms.
Add widgets only to visible elements.

That way they're not added to hidden empty form templates. The form
template is cloned when using dynamic formsets. In my experience
the timepicker and select2 get mighty confused when they are cloned.
Therefore the idiom is to leave the hidden empty form without widgets and
attach them after they become visible.
Limit widget initialization to a provided scope.