Can we pass argument to a form from a Twig template I have a form that accepts a custom argument sourceid

 public function buildForm(array $form, FormStateInterface $form_state, $sourceid = NULL)


Now, this form is displayed in a twig template multiple times using a for loop.
For each instance of this form the sourceid is different in the twig template.
The value of the sourceid is present in the twig template. Can I pass it to the form from the twig template itself? Or should I modify my controller and render the form in the template along with the id?

Code in the twig template displaying the form is as follows:

{% for item in field %}
    {% if item.content %}
      &lt;p&gt; {{ item.content|raw }} &lt;/p&gt;
      &lt;p&gt; {{ item.sourceid|raw }} &lt;/p&gt;
      &lt;div&gt;{{ metadata_form }}&lt;/div&gt;
    {% endif %}
(% endfor %}


The variable metadata_form has the form element in it.
I think the most elegant way is to modify your controller so all the logic happens in the controller and only the markup in twig. If you have that option that's the way to go.

That being said, there are ways to get what you want.
The most convenient way I know is the twig_tweak module and use the function 

{{ drupal_form('yourmodule\\namespace\\Form\\yourForm', sourceid) }}


I have not tested it myself but it should work.