It looks like you are trying to recreate the most from inside the form itself, which is likely leading to your issues. I would try getting the original form and just adding the fields for the attributes to that, and re-displaying it. EDIT: Removed ISC Reference.
EDIT: It looks like you may be trying to follow this IIQ suggestion in the first post for creating the form dynamically:
I would consider creating the form dynamically in an initial step like @patrickboston suggests, then use it in the following step.
Additionally, you are recreating the buttons that you already have created, so there may be some issue with those conflicting with eachother. i would remove the buttons from the custom code and leave the ones on the original form and try that.