Islam and "Pants Shirt"

Yes, if there is no dress code then there is no compulsion.

Many times the codes are not actually written but we still try hard to comply with anyway.
I gave example of going to some restaurants at dinner time.

" because your teacher said so"....... nothing wrong with that.

Perhaps the child will learn to respect teacher's wish.

There are so many things kids are asked to do in other schools and parents make sure they comply with the request. No questions are asked.