Bonjour tous le monde,
étant novice sur zf2 je bloque sur un problème. Ce dernier étant le fait que ma child route me redirige vers la page de default établie dans le defaults de la route parent mais l'url de mon navigateur est celle du de la child route.
Si vous voyez le problème je suis preneur.

Voici le fichier module.config.php
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
 
'projet' => array(
                'type' => 'Segment',
                'options' => array(
                    'route' => '/projet[/][:action][/:idprojet]',
                    'constraints' => array(
                        'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
                        'idprojet' => '[0-9]+',
                    ),
                    'defaults' => array(
                        'controller' => 'Application\Controller\Projet',
                        'action' => 'listProjet',
                    ),
                ),
                'may_terminate' => true,
                'child_routes' => array(
                    'tache' => array(
                        'type' => 'segment',
                        'options' => array(
                            'route' => '/[:actiontache[/:idtache]]',
                            'constraints' => array(
                                'actiontache' => '[a-zA-Z][a-zA-Z0-9_-]*',
                                'idtache' => '[0-9]+',
                            ),                            
                        ),
                    ),
                ),                
            ),
voici comment je gère le lien:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 
foreach ($taches as $tache):
            ?>
            <tbody>
                <tr>                         
                    <td><?php echo $tache->getId_tache(); ?></td>
                    <td><?php echo $tache->getTitre_tache(); ?></td>
                    <td><?php echo $tache->getDescription_tache(); ?></td>
                    <td><?php echo $tache->getDate_debut()->format('d-m-Y H:m:s'); ?></td>
                    <td><?php echo $tache->getDate_fin()->format('d-m-Y H:m:s'); ?></td>
                    <td>
                        <a href="<?php echo $this->url('projet/tache', array('idprojet' => $projet->getId_projet(), 'actiontache' => 'EditTache','idtache'=>$tache->getId_tache(), true)); ?>">Edit</a> |
 
                    </td>
                </tr>
            </tbody>
    <?php endforeach; ?>
le controler:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 
public function editTacheAction()
    {
        $idTache = (int) $this->params()->fromRoute('idtache', 0);
        $tache = $this->getObjectManager()->find('\Application\Entity\Tache', $idTache);
 
        if ($this->request->isPost()) {
            $tache->setTitre_tache($this->getRequest()->getPost('titre_tache'));
            $tache->setDescription_tache($this->getRequest()->getPost('description_tache'));
            $tache->setDate_debut_tache(new \DateTime($this->getRequest()->getPost('date_debut')));
            $tache->setDate_fin_tache(new \DateTime($this->getRequest()->getPost('date_fin')));            
 
            $this->getObjectManager()->persist($tache);
            $this->getObjectManager()->flush();
 
            return $this->redirect()->toRoute('projet/tache');
        }
 
        return new ViewModel(array('tache' => $tache));
    }
et la vue:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
 
<?php
 
$title = $tache->getTitre_tache();;
$this->headTitle($title);
?>
<h1><?php echo $this->escapeHtml($title); ?></h1>
<form method="post">
 
  Titre: <input type="text" name="titre_tache" value="<?php echo $tache->getTitre_tache(); ?>"><br>
  Description: <textarea name="description_tache"><?php echo $tache->getDescription_tache();?></textarea><br>
  Début: <input type="date" name="date_debut" value="<?php echo $tache->getDate_debut()->format('d-m-Y H:m:s'); ?>"><br>
  Fin: <input type="date" name="date_fin" value="<?php echo $tache->getDate_fin()->format('d-m-Y H:m:s'); ?>"><br>
 
  <input type="submit" value="Valider">
</form>