Fixes issue 401 which causes error when nested form created programatica...

@jzaefferer: This PR replaces issue #401.