Fix #10548 (crash using custom forms)

When using a custom UI file, the widget is created beforehand,
and the code was failing to initialize it.