My Symfony2 form has a text field containing the entity's ID.
I used the following to achieve this:
$formBuilder->add('id', TextType::class, ['attr' => ['readonly' => true]])
readonly is for clients. It indicates that client can't change the value of the element. But it is going to be submitted with form.
If you don't want element's value to be submitted use