Fixed #19617 -- Refactored form metaclasses to support more inheritance scenarios.