YouFor simple forms ...
... you can theme a form
template by using {{ element }}
instead of {{ children }}
, see How to Create twig template files in drupal 8 for customizing user login,profile edit and forget password forms?.
But this is not always the best approach, because it's difficult to include all form elements and metadata the form needs to operate.
ItFor complex forms ...
... it might be easier to add a custom forman additional template in a form alter hooklevel, which then only has to render the inner form elements, not the complete form:
/**
* Implements hook_form_FORM_ID_alter() for \Drupal\user\RegisterForm.
*/
function mytheme_form_user_register_form_alter(&$form, FormStateInterface $form_state) {
$form['#theme'] = 'user_register_form';
}
The custom template needs to be registered in hook_theme
, see. See How to render specific form elements from the *.theme file for a step-by-step example.