Get form value

0

This is my twig form.

<form id="csv" action="{{ path('faturamento_csv') }}" method="post">
    {% for elm, value in filtroLocais %}
         <input type="hidden" name="{{ elm }}" value="{{ value }}">
    {% endfor %}
         <button class="btn btn-primary" type="submit">
              <i class="icon-bar-chart"></i>
              Gerar CSV
         </button>
</form>

As a result of the form I have this:

<input type="hidden" value="25" name="0">
<input type="hidden" value="147" name="1">

How do I get these values correctly on the Controller? From what I can identify, the form does not send any value with the name "idLocal"

            $form = $this->createForm( new LogPesquisaType() );
        $form->bind( $request );
        $data = $form->getData();

        $filtroLocais = array(); // Inicializa array com locais a pesquisar
        foreach ( $data['idLocal'] as $locais ) {
                array_push( $filtroLocais, $locais->getIdLocal() );
        }

        $printers = $this->getDoctrine()->getRepository( 'CacicCommonBundle:LogAcesso')
                ->faturamentoCsv( $data['dtAcaoInicio'], $data['dtAcaoFim'], $filtroLocais);
    
asked by anonymous 27.08.2014 / 17:04

1 answer

0

But you're trying to get the $data['idLocal'] of the array but it does not exist

here $data = $form->getData(); does so $data['idLocal'] = $form->getData(); if I'm not mistaken already solve your problem

    
27.08.2014 / 21:38