Consultez la FAQ sur le ZF avant de poster une question
Vous n'êtes pas identifié.
Bonjour,
Voila mon code :
<p><a href="<?php echo $this->url(array('controller'=>'index',
'action'=>'ajouter'));?>">Ajouter</a></p>
à l'affichage de la page web, j'ai un lien "Ajouter", je voudrais le remplacer par un bouton "Ajouter".
Comment faire ?
Hors ligne
echo $this->formButton("Ajouter");
Apres tu n'a plus qu'a faire du javascript pour que sur click ça redirige vers ton url
Hors ligne
Merci pour la réponse, mais cela ne marche pas. En fait, voici le code complet :
<p><a href="<?php echo $this->url(array('controller'=>'index',
'action'=>'ajouter'));?>">Ajouter un album</a></p>
<table>
<tr>
<th>Artiste</th>
<th>Titre</th>
<th>Date Création</th>
<th> </th>
</tr>
<?php foreach($this->albums as $album) :;?>
<tr>
<td><?php echo $this->escape($album->artiste);?></td>
<td><?php echo $this->escape($album->titre);?></td>
<td><?php echo $this->escape($album->datecreation);?></td>
<td>
<a href="<?php echo $this->url(array('controller'=>'index',
'action'=>'modifier', 'id'=>$album->id));?>">Modifier</a>
<a href="<?php echo $this->url(array('controller'=>'index',
'action'=>'supprimer', 'id'=>$album->id));?>">Supprimer</a>
</td>
</tr>
<?php endforeach; ?>
</table>
Je voudrais remplacer ">Ajouter un album par un bouton. Je suis novice dans Zend Framework et PHP.
Hors ligne
Salut,
je te propose comme solution soit de passer par un formulaire bidon (je sais pas si sa se fait) où tu lui mets ton bouton avec l'action qui va bien
<form action=<?php echo $this->url(array('controller'=>'index','action'=>'ajouter'));?>> <input type="submit" value="Ajouter un album"/> </form>
Soit tu joues avec ta feuille de style CSS pour que le lien ressemble à un bouton.
Hors ligne
Merci beaucoup Godzinho, peux-tu me dire comment faire ce qui suit ?
Voici à nouveau le code :
<form action=<?php echo $this->url(array('controller'=>'index',
'action'=>'ajouter'));?>><input type="submit" value="Ajouter un album"/>
</form>
<table>
<tr>
<th>Artiste</th>
<th>Titre</th>
<th>Date Création</th>
<th> </th>
</tr>
<?php foreach ($this->albums as $album) :; ?>
<tr>
<td><?php echo $this->escape($album->artiste); ?></td>
<td><?php echo $this->escape($album->titre); ?></td>
<td><?php echo $this->escape($album->datecreation); ?></td>
<td>
<form action=<?php echo $this->url(array('controller'=>'index',
'action'=>'modifier', 'id'=>$album->id));?>>
<input type="submit" value="Modifier"/>
</form>
<form action=<?php echo $this->url(array('controller'=>'index',
'action'=>'supprimer', 'id'=>$album->id));?>>
<input type="submit" value="Supprimer"/>
</form>
</td>
</tr>
<?php endforeach; ?>
</table>
Cela marche bien, ma question est comment metrre côte à côte les boutons "Modifier" et "Supprimer" ?
Ils s'affichent sur 2 lignes.
Hors ligne
J'ai trouvé la solution.
Merci à tous.
Hors ligne