Add popup_form function, manage form life-cycle