- 1
[Opened] Personalisation Formulaire avec balise Select [résolu]
Posted by Didou on 08/23/2012 14:52
Bonjour,
J'ai une table po_spectacles avec pour dernier champ id_tarifs qui correspond à la clé primaire de ma table po_tarifs.
Lors de la création d'un nouveau enregistrement dans po_spectacles je souhaiterai pouvoir choisir dans une liste déroulante le tarif qui s'applique aux spectacle (on affiche pas id_tarifs mais les champs tarif_a, tarif_b... dans la liste déroulante).
Voila ce que j'ai fait :
Controleur speccrud.classic.php :
<?php
/**
* @package ptitouest.fr
* @subpackage adminprog
* @author Didou Mimamou
* @copyright 2012 www.mimamou.fr
* @link http://www.mimamou.fr
* @license All rights reserved
*/
class speccrudCtrl extends jControllerDaoCrud {
/**
*
*/
protected $dao = 'commun~po_spectacles';
protected $form = 'commun~specform';
protected $editTemplate = 'adminprog~crud_edit';
protected function _create($form, $resp, $tpl) {
$fact_tarifs = jDao::get('commun~po_tarifs');
$tarifs = $fact_tarifs->findAll();
$tpl->assign('tarifs', $tarifs);
}
}
Template correspondant :
if $id === null}
<h1>{@jelix~crud.title.create@}</h1>
{form $form, $submitAction}
<table class="jforms-table" border="0">
{formcontrols array('id_spectacles', 'titre', 'auteur', 'age_minimum', 'age_maximum', 'duree', 'synopsis')}
<tr>
<th scope="row">{ctrl_label}</th>
<td>{ctrl_control}</td>
</tr>
{/formcontrols}
{formcontrols array('id_tarifs')}
<tr>
<th scope="row">{ctrl_label}</th>
{/formcontrols}
<td><select name="id_tarifs" id="jforms_commun_specform_id_tarifs" class="jforms-ctrl-select">
{foreach $tarifs as $listetarifs}
<option value="{$listetarifs->id_tarifs}">Tarif A : {$listetarifs->tarif_a} / Tarif B : {$listetarifs->tarif_b} / Tarif C : {$listetarifs->tarif_c}</option>
{/foreach}
</select></td>
</tr>
</table>
<div> {formsubmit} </div>
{/form}
{else}
<h1>{@jelix~crud.title.update@}</h1>
{formfull $form, $submitAction, array('id'=>$id, $offsetParameterName=>$page)}
{/if}
<p><a href="{jurl $listAction, array($offsetParameterName=>$page)}" class="crud-link">{@jelix~crud.link.return.to.list@}</a>.</p>
Mais rien ne s'affiche dans ma liste déroulante.... J'ai juste "Tarif A : Tarif B : Tarifs C :" Apres si ce n'est pas la bonne méthode n'hésitez pas à m'en proposer une autre.
Merci d'avance
[edit : en fait ça marche, un copier coller maladroit et donc il y avait un fetch de trop... désolée ^^]
Adeline
- 1

