v2.1.3: Prevents error when no entity is set
Ensures that entity checks and form setting are only performed if an entity has actually been set, preventing potential errors when no entity is provided. Also enforces type hinting for the entity parameter to ensure it is an object.