Polymorphing into a creature that is larger than the room

If a character has the ability to transform into different creatures (using polymorph or wildshape as examples), what would happen if they shift into a creature larger than the space they are in?

Example: a chartacter is in an 8x8x8 room and turns into an elephant via any shape changing spell/ability.

Would the polymorph or wildshape still take effect?

Would the character take damage and if so how would that be determined?

Would any other creatures in that room take that same amount of damage?