How to create Read-only fields
There are many ways to create a read-only field:
- Unset the field, and just display the value in the template: The good thing is that it's pretty straight forward. The bad thing is that you're messing with the template and the form logic is not in the form object anymore so some of your fields and labels are managed by the form object and the read-only forms are not managed by the form object anymore. It's not consistent. Plus, you'll miss all the doctrine magic in the drop-down lists fields.
- Create a validator: The good thing is you don't need to touch the template and you use all of the form logic and field's label. The bad thing is that it is not very user-friendly to let the user modify the field and only tell him it's forbidden after he submits the form when you could prevent him from touching the field in the first place.
- Output the form field but hide it and show only the form field's value (=read-only) to the user. Then, prevent the field from being saved. The good thing is that this uses the form object, so you can use the form logic and the field's label from the form object. The other good thing is that you can use doctrine's magic in the drop-down fields. The bad thing is that the changes spread throughout the code and you're messing with the template...