How to fined the fields biggest weight in form
the solution is in this code: 

  $elements = Element::getVisibleChildren($form);
  $weight = 0;
  foreach ($elements as $el) {
    $check = strpos($el, 'field_');
    if ($check !== FALSE &amp;&amp; $form[$el]['#weight'] &gt;= $weight) {
      $weight = $form[$el]['#weight'];
    }
  }


  $form['register'] = [
    '#type' =&gt; 'submit',
    '#value' =&gt; t('Register'),
    '#submit' =&gt; array('NAME_OF_A_FUNCTION'),
    '#weight' =&gt; $weight + 1,
  ];