Try not to alter the form this way. You can easily generate the action URL in controller and pass it as a form option to your form type. In buildForm() method, use the $options array and set the action from that option. You can also define form method in the buildForm() method. I never experimented with enctype, but I guess the approach would be similar.
A beautiful example how your twig template with a form should look like: