Recently when creating a form within Symfony2 I came across the need to get the label of a form field, before having called createView()
.
After a bit of digging around it turns out you can use the following:
<?php
$form = $this->createForm(new FormType(), null);
$options = $form->get('field')->getConfig()->getOptions();
$label = !empty($options["label"]) ? $options["label"] : "label being generated from field name";
?>