I'm new in PHP and I'm trying to pass 2 integers to from my view to my controller. I'm using zend framework 2.
This is the way I was trying to pass the data to my action in controller through a button, but the values that I receive in my action are equal to 0, so it's wrong because I have values that not equal to 0.
<td>
<?php $url = $this->url('mediador', array('action' => 'associaCorrespondencia', 'idCompra' => $Compra[$i]['ID'], 'idVenda' => $Venda[$i]['ID'])); ?>
<form action="<?php echo $url; ?>" method="post">
<div>
<input type="submit" name="del" value="Associar" />
</div>
</form>
<td>
Here is how I receive the values in my action :
public function associaCorrespondenciaAction(){
$idCompra = $this->params()->fromRoute('idCompra', 0);
$idVenda = $this->params()->fromRoute('idVenda ', 0);
}
What Am I doing wrong? The values that I receive are ever equal to zero, and are not the same ones I went through parameter. Thanks in advance!
EDIT: My route config:
<?php
return array(
'controllers' => array(
'invokables' => array(
'Mediador\Controller\Mediador' => 'Mediador\Controller\MediadorController',
),
),
// The following section is new and should be added to your file
'router' => array(
'routes' => array(
'mediador' => array(
'type' => 'segment',
'options' => array(
'route' => '/mediador[/:action][/:id]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
),
'defaults' => array(
'controller' => 'Mediador\Controller\Mediador',
'action' => 'index',
),
),
),
),
),
'view_manager' => array(
'template_path_stack' => array(
'Mediador' => __DIR__ . '/../view',
),
),
);