Refactor buttons generation for forms