Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> HTML_QuickForm + smarty -> validacja
zbynio4
post
Post #1





Grupa: Zarejestrowani
Postów: 18
Pomógł: 0
Dołączył: 18.06.2004

Ostrzeżenie: (0%)
-----


Probuje opanowac HTML_QuickForm + Smarty i mam dowielce szanownych kolegow pytanie a moj problem trudny do pokonania.

Prosty formularz i prosty szablon,
przesyla dane ale nie ma validacji - co jest zle (IMG:http://forum.php.pl/style_emoticons/default/questionmark.gif)
  1. <?php
  2. require_once "lib/HTML/QuickForm.php";
  3. require_once 'lib/HTML/QuickForm/Renderer/ArraySmarty.php';
  4. require_once 'lib/Smarty.class.php';
  5.  
  6.  
  7. $form = new HTML_QuickForm('frmTest', 'post');
  8.  
  9. $form->addElement('header', 'MyHeader', 'Test:');
  10.  
  11. $form->addElement('text' ,'nick', 'Nr GG:' ,array('size' => 12, 'maxlength'=> 12));
  12. $form->addElement('text' ,'email' ,'Email:',array('size' => 23, 'maxlength' => 40));
  13. $form->addElement('submit','btnSubmit', 'OK','class="button"');
  14.  
  15. $form->addRule('nick' , 'Podaj nick' , 'required', 'null', 'client');
  16. $form->addRule('email', 'Podaj adres Email!', 'required', null, 'client');
  17.  
  18.  
  19. if ($form->validate()) {
  20. $form->freeze();
  21. $form->process('dopisz_do_bazy', false); // dopisanie do bazy
  22. $form->process('process_list' , false);  // podziekowanie
  23.  
  24. } else {
  25. $renderer =& new HTML_QuickForm_Renderer_ArraySmarty($smarty);
  26. $form->accept($renderer);
  27. $smarty = new Smarty();
  28. $smarty->assign('new', $renderer->toArray());
  29. $smarty->display('test.tpl');
  30. //$form->setDefaults($user);
  31. //$form->display();
  32.  
  33. }
  34. ?>


szablon test.tpl
  1. {$new.javascript}
  2. <form {$new.attributes}>
  3. <tr>
  4. <td>{$new.email.label}</td>
  5. <td>{$new.email.html}<br />
  6. {$new.requirednote}
  7. </td>
  8. </tr>
  9. <tr>
  10. <td></td>
  11. <td>{$new.btnSubmit.html}</td>
  12. </tr>
  13. </form>


Dziala, przesyla dane metoda post i get a za chiny ludowe nie sprawdza czy pole email zawiera jakiekolwiek dane. Pomocy koledzy bo juz naprawde nie mam pojecia.

Z gory dzieki za pomoc

Ten post edytował zbynio4 20.07.2006, 22:46:04
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 25.08.2025 - 08:49