Potty training help

Hi my 2 year old (boy) will go to the potty as long as he's bottom less, but as soon as we put on a pull up or underwear he pees and poops in them... Plz tell me what to do next