Submitting a form, when using the same form with different ID are on a page Here is what happens:
I've create a content type poll, which admin can create polling questions and answers. Then this polling node will be rendering in a new Page node with node reference (using paragraph).

I manage to create a paragraph preprocess on .theme which will pass the NID to the buildForm.

Here is how it looks like on preprocess:

function THEME_preprocess_paragraph__poll_and_sidebar(&amp;$variables) {
  $paragraph = $variables['paragraph'];
  $poll_form = '';
  if (!$paragraph-&gt;field_poll_content-&gt;isEmpty()) {
    $node_id = $paragraph-&gt;field_poll_content-&gt;getValue();
    $nid = $node_id[0]['target_id'];
    $poll_form = \Drupal::formBuilder()-&gt;getForm('Drupal\mypoll\Form\PollForm', $nid);
  }
  $variables['poll_form'] = $poll_form;
}


The myPoll buildForm module:

 public function buildForm(array $form, FormStateInterface $form_state, $nid= null) {

if (!$nid == null) {

  // check if user have voted
    $get_count_voter = $this-&gt;queryVoter($_COOKIE['cusid'],$nid);

  // Function on node load
    $poll_form_result = $this-&gt;getPollDetail($nid); 

    $each_answer = [];

    foreach ($poll_form_result['answers'] as $answer_value) {
      $each_answer_id = $answer_value-&gt;id();
      $each_answer['answer'][$each_answer_id] = $answer_value-&gt;get('field_polling_answers')-&gt;value;
      $each_answer['calc'][$each_answer_id] = $answer_value-&gt;get('field_answers_calculation')-&gt;value;
    }

    $answer_type = 'checkboxes';

    if ($poll_form_result['poll_type'] == 'linear' || $poll_form_result['poll_type'] == 'multiple_2') {
      $answer_type = 'radios';
    }

    $form['poll_'.$nid] = [
      '#markup' =&gt; '',
    ];

    $form['poll_'.$nid]['headline'] = [
      '#markup' =&gt; '&lt;h3&gt;' . $poll_form_result['headline'] . '&lt;/h3&gt;'
    ];

    $form['poll_'.$nid]['question'] = [
      '#markup' =&gt; '&lt;p&gt;' . $poll_form_result['question'] . '&lt;/p&gt;'
    ];

    $form['poll_'.$nid]['sub_question'] = [
      '#markup' =&gt; '&lt;p class="poll__question"&gt;' . $poll_form_result['sub_question'] . '&lt;/p&gt;'
    ];

  if ($get_count_voter == true) {

    $form['poll_'.$nid]['answers'] = array(
      '#type' =&gt; $answer_type,
      '#options' =&gt; $each_answer['answer'],
    );

    $form['poll_'.$nid]['poll_type'] = [
      '#type' =&gt; 'hidden',
      '#value' =&gt; $poll_form_result['poll_type'],
    ];

    $form['poll_'.$nid]['poll_user_cookie'] = [
      '#type' =&gt; 'hidden',
      '#value' =&gt; $_COOKIE['cusid'],
    ];

    $form['poll_'.$nid]['poll_nid'] = [
      '#type' =&gt; 'hidden',
      '#value' =&gt; $nid,
    ];

     $form['poll_'.$nid]['actions']['#type'] = 'actions';
      $form['poll_'.$nid]['actions']['submit'] = array(
      '#type' =&gt; 'submit',
      '#value' =&gt; $this-&gt;t('Submit'),
      '#button_type' =&gt; 'primary',
      '#name' =&gt; 'submit-'.$nid,
      '#attributes' =&gt; array(
        'class' =&gt; array(
          'button--darkblue'
       ),
        'id' =&gt; array(
          'submit-'.$nid
        ),
      ),
   );

  } else {

    $form['poll_'.$nid]['result'] = [
    '#markup' =&gt; $this-&gt;t('RESULT'),
  ];

  }
    return $form;
}
}


On 1 page there will be more than 1 polls, for this example, I will have 2 sets of polling and it was successfully display 2 sets of forms but when I click submit button on the 2nd form , and trying to dump $form_state, it always pickup the 1st form value.

Is there a way I can define the Form ID by NID or any suggestion on fix?

Thanks,
Queenie
You need to call your form like this:

$form = new Drupal\mypoll\Form\PollForm($nid);
$poll_form = \Drupal::formBuilder()-&gt;getForm($form);


Then add this methods to your form class:

protected $nid;

public function __construct($nid)
{
  $this-&gt;nid = $nid;
}

public function getFormId()
{
  return 'my_form-' . $this-&gt;nid;
}


And you need to make sure that $nid is different each time the form is on the page.