I'm creating a custom form using Symfony2. I created the "first part" of the form using Symfony as the following code:
class TelemedidaMecanicaLecturaType extends AbstractType{
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options) {
$builder
->add('fecha')
->add('valor')
;
}
}
Then, in the Twig template I need to add three extra fields: the submit button and two hidden inputs that I need to get some important information. I tried to do that:
<form method="post" id="FormLec{{um.id}}">
{{ form_widget(formLecArr[um.um]) }}
<input type="hidden" name="um" value="{{um.id}}"/>
<input type="hidden" name="telemedidaMecanica" value="{{telemedidaMecanica.id}}"/>
<input type="submit" value="Crear"/>
</form>
But when I send the form, and I try to get data from the controller, I only get "fecha" and "valor" values. It is strange, because missing fields are displayed in the HTML text (using inspect code utility in chrome) and the submit button works correctly. Where is the "um" and "telemedidaMecanica" values? What I am doing wrong?
Thank you! Isaac.