fixes #5028 Relating to a widget does not display fields correctly

Fixed the issue and pushed the code for review, please check it.