I am writing custom template to style my "edit user profile" form page.

Below is the code in twig file :

  {{ form.first_name }}

  {{ form.last_name }}

  {{ form.account.mail }}

  {{ form.account.current_pass }}

  {{ form.account.pass }}

  {{ form.actions }}

  {{ form|without('first_name', 'last_name', 'account.mail', 'account.current_pass', 'account.pass', 'actions') }}

The Problem is that it is print all account field for example account.mail. I guess it is is not understood by "without" function and it prints that field twice so I am unable to print all account custom field elements individually.

Here is the Dump output of twig form:

enter image description here

It is very important to print rest of the form using "without" function but "without" function printing my custom account field twice and not understanding that it is already printed on page.

Also I tried to directly use "account" as argument in without function which is working fine but this may miss some important content render which is present in account array. I want to render all account data except the fields which I want to print individually.

  • 1
    Have you come across any documentation that would suggest using syntax like account.mail would work? The code would suggest without is one-dimensional, it doesn't do any special processing for render arrays within render arrays
    – Clive
    Jan 22, 2020 at 12:42
  • It should be {{ form|without('account') }} as @Clive says works only for one-dimmesion, you cannot nest keys.
    – d70rr3s
    Jan 22, 2020 at 17:55

1 Answer 1


try to print it this way it gives you more control :

<div id="candidature_spontanee" class="form-contact candidature_spontanee">

{# 1.use the attribute to set the form action and other attributes #}
<form{{ attributes }}>
 {{ title_prefix }}
 {{ title_suffix }}

     {# 2.print the form elment using : {{ element.elements.key }} #}
     <div class="js-form-item form-item js-form-type-textfield form-item-nom js-form-item-nom form-group custom-input">
       {{ element.elements.nom }}
       <div class="help-block with-errors"></div>

     <div class="js-form-item form-item js-form-type-textfield form-item-nom js-form-item-nom form-group custom-input">
       {{ element.elements.telephone }}
       <div class="help-block with-errors"></div>

     {# 3.print the captcha if you have a cpatcha #}
     {{ element.captcha }}

     {# 4.you need to output a couple of hidden form elements that is required for the form to be submitted properly and securilly#}
     {{ element.form_token }}
     {{ element.form_build_id }}
     {{ element.form_id }}

     {# 5.output the form action (submit) at the end of the form link  #}
     {{element.actions }}



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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