[PEAR][HTML_QuickForm] Utilisation de AddRule()
Bonjour,
Je n'arrive pas à mettre en place AddRule(), j'ai pourtant regardé au préalable les tutos de developpez.net avant de poster ce message :
Le AddRule n'est pas pris en compte et au click sur le bouotn submir , je passe sur la seconde page affiché par $tpl->display("sc_conf.ihtml");
J'ai essayé AddRule avec "uploadedfile" et "required" afin de controler qu'un fichier à uploader à bien été sélectionné.
Code:
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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
| <?
#Pear library
require_once "HTML/QuickForm.php";
require_once 'HTML/QuickForm/select.php';
require_once 'HTML/QuickForm/Renderer/ArraySmarty.php';
$form = new HTML_QuickForm('form_masse','post','oreon.php?p=60921');
#Path to the configuration dir
global $path;
$path = "./modules/aaa/";
#PHP functions
require_once $path."Punc.php";
# Smarty template Init
$tpl = new Smarty();
$tpl = initSmartyTpl($path, $tpl);
$tpl->assign("SC_INFO_1",$lang['sc__info_1']);
$tpl->assign("SC_INFO_2",$lang['sc_info_2']);
$form->addElement('file','conf_1',$lang['sc_titre_1']);
$form->addRule('conf_1', 'Vous devez renseigner le champ', 'uploadedfile');
$form->addElement('file','conf_2',$lang['sc_conf_masse_titre_2']);
$form->addRule('conf_2', 'Vous devez renseigner le champ', 'required');
$form->addElement("submit","submit" , $lang['sc_conf_masse_save']);
$form->addElement("reset", "reset", $lang['sc_conf_masse_del']);
// Create the renderer object
$renderer =& new HTML_QuickForm_Renderer_ArraySmarty($tpl);
// build the HTML for the form
$form->accept($renderer);
// assign array with form data
$tpl->assign('form', $renderer->toArray());
$tpl->assign('o', $o);
$tpl->assign('use_lca', $use_lca);
//Ajout de code supplémentaire
if ($form->validate()) {
# If the form validates then freeze the data
/* $form->freeze();*/
}
else{
// parse and display the template
$tpl->display("sc_conf.ihtml");
}
?> |
Merci d'avance!