-2

I am looking for a "user-register-form.html.twig" for custom position of field in the page with twig.

This is what i would like for the designer :

<div class="row">

  <div class="col-md-6">
    {{ form.field_name }}
  </div>

  <div class="col-md-6">
    {{ form.field_surname }}
  </div>

</div>

Someone know how to make a custom user form template ?

  • I think your best bet might be to use something like Field Group, not sure what the D8 porting status of that is. – Cottser Jul 15 '15 at 23:42
  • i prefer make a template suggestion in my module – Kevin Jul 16 '15 at 7:50
  • Please don't downvote without adding a comment as to why! – Kevin Jul 29 '15 at 11:55
1

Your approach is good, you just need to add the {{ form|without('field_name', 'field_surname') }} at the end of the file. And the file would be more like a form--user-register.html.twig since it is a form so that is the first keyword. The issue with this is that it won't look like you would like to since you would have to position all fields from the form on proper places and make sure you get all of them which makes is quite tricky if you would remove or add new fields to user profiles and make them dis/appear on the registration form.

Depending on the outcome you are looking for there are a multiple ways of achieving the goal. You could alter the form and wrap specific fields in a custom theme handler, processor or after builder, or you could alter the builded render array, etc...

  • thx jaros, in fact i want a simple way for designer for custom the page, i can wrap but designer cannot work on this like he want. so in my module, i would like a template for this form with all my fields so he can move fields like he want in another custom template – Kevin Jul 16 '15 at 14:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.