Fixed #15877 -- Improved exception when ModelForm has no model class

Thanks theaspect at gmail.com for the report and volrath for the
patch.
Fixed errors introduced in 21f333bcefccc151d6439246f8203d609ab6ca79. Refs #17751
Fixed errors introduced in 664855b74e1f417384dc7aef35a3df5f86db52d6