He—may Allah have mercy on him—was asked:
A man led a congregation in a four-rak‘ah prayer, forgot the tashahhud, and stood up. Some of them alerted him by saying “Glory be to Allah,” but he did not sit back down. He completed his prayer, prostrated, and pronounced the salām. Some said, “He should have been made to sit back down,” while others said, “Had he sat back down, his prayer would have been invalid.” Which group is correct?
He replied:
The imam who missed the first tashahhud and stood up, then did not return to sitting when alerted, but prostrated for forgetfulness before the salām, acted correctly. This is authentically reported from the Prophet, may Allah bless him and grant him peace. Whoever says that he should have sat back down is mistaken; rather, what he did was better.
As for the claim that returning to sitting would have invalidated his prayer, the scholars hold two views:
The first is that returning would have invalidated his prayer. This is the position of al-Shāfi‘ī and of Ahmad according to one reported opinion.
The second is that if he returned before beginning the recitation, his prayer would not have been invalidated. This is the well-known opinion reported from Ahmad. And Allah knows best.