1.ã¯ããã«ã
ãã®èšäºã¯äœã«ã€ããŠã§ããïŒ
ãã®èšäºã¯ãPEAR HTML_QuickFormã¯ã©ã¹ã§Smartyãã³ãã¬ãŒãã䜿çšããããã®ç°¡åãªçŽ¹ä»ã§ãã ãã®èšäºã¯ç¶²çŸ çãªã¬ã€ãã§ã¯ãªããå®éã«ã¯Smartyãã³ãã¬ãŒãã®æ©èœã®ããäžéšã«ãããŸããã ãã ããSmartyãã³ãã¬ãŒãã䜿çšããåå¿è ã«ãšã£ãŠã¯ããã®èšäºã圹ç«ã€è³æã«ãªããŸãã
翻蚳è 泚ïŒHabrã¯HTMLã解æãããããäžéšã®å Žæã§ã¯ã³ãŒããã¹ã¯ãªãŒã³ã·ã§ããã®åœ¢åŒã§è¡šç€ºãããŸãã
åææ¡ä»¶ã
PHPãšPEARãæ¢ã«ã€ã³ã¹ããŒã«ãããŠãããPHPãšHTMLã«ç²ŸéããŠããããšãç解ãããŸãã PEAR HTML_QuickFormã¯ã©ã¹ã®äœ¿çšã«ã粟éããŠããå¿ èŠããããŸãã PEAR Webãµã€ãã§PEARã®ãã«ããååŸã§ããŸããPHPWebãµã€ãã§PHPã®ãã«ããååŸã§ããŸãã ãŸã ã å¥ã®èšäºã§ HTML_QuickFormã®äœ¿çšã®æŠèŠãèŠã€ããããšãã§ããŸãã
ãã®èšäºã¯å®çšçãªèŠ³ç¹ããæžãããŠããŸãã æ倧éã«æŽ»çšãããå Žåã¯ããããããµã³ãã«ã³ãŒããã³ããŒããŠãèªåã§å®è¡ããå¿ èŠããããŸãã ãšãããããã³ãã¬ãŒãã¯æ å ±ãè¡šãããã«äœ¿çšããããã®èšäºã§ã¯ããŒã¿åºåã®äŸãæäŸããŠããŸããã åäœäžã®ãã¿ãŒã³ãèŠããå Žåã¯ãèªåã§ã³ãŒããå®è¡ããå¿ èŠããããŸãã æåŸã«ããã®èšäºã§çŽ¹ä»ããã³ãŒãäŸã¯ãSmartyãã³ãã¬ãŒãã®ã¿ã®äœ¿çšãè¡šãããšãç®çãšããŠããŸãã ã€ãŸãããã³ãã¬ãŒãé¢æ°ãããæ確ã«è¡šãããã«ãããŒã¿æ€èšŒãªã©ã®é¢æ°ã¯çç¥ãããŠããŸãã
2.ã¡ã€ã³ãã©ãŒã ã
çãã¬ãã¥ãŒã
ãã³ãã¬ãŒãã䜿çšããªãã·ã³ãã«ãªãã©ãŒã ããå§ããŸãããã åŸã§ãã¿ãŒã³ã䜿çšããããã«å€æŽããŸãã
次ã®ãã¡ã€ã«ãäœæããWebãµãŒããŒãã¢ã¯ã»ã¹ã§ãããã©ã«ããŒã«é 眮ããŠããã©ãŠã¶ãŒã«ãã¡ã€ã«ã衚瀺ããŸãã

ãã©ãŒã ã衚瀺ãããæ å ±ãå ¥åããŠããŒã¿ãéä¿¡ããå¿ èŠããããŸãã ãã®åŸãããŒãžã¯éçãªåœ¢åŒã®æ å ±ã§ãªããŒããããŸãã ãããæ©èœããªãå ŽåããŸãã¯æ©èœããçç±ãããããªãå Žåã¯ã 次ã®èšäºãåç §ããŠãã ãã ã
äžèšã®ã³ãŒãã«ã€ããŠã次ã®ããšã«æ³šæããŠãã ããã
- PHP / PEARã³ãŒããšHTMLãå«ãŸããŠããŸãã
- 衚瀺ãããHTMLã®ãã©ãŒãããã«åœ±é¿ãäžããæ確ãªæ¹æ³ã¯ãããŸããã
3.ã¡ãã£ãšããçè«ã
ãã³ãã¬ãŒãã¯äœã«äœ¿çšãããŸããïŒ
äžèšã®äŸã§èŠãããã«ãããã©ã«ãã§ã¯ãPEAR HTML_QuickFormã¯ã©ã¹ã«ãã£ãŠäœæããããã³ãã¬ãŒãã¯éåžžã«ç°¡åãªæ¹æ³ã§è¡šç€ºãããŸã-åŸç¶ã®ãã©ãŒã ãšèŠçŽ ã®äžã«ã·ã§ãŒãã«ããã衚瀺ãããŸãã
å®è¡å¯èœã§ããããããããã®ãã©ãŒã ã«ã¯ããããã§ãã·ã§ãã«ãªã¢ããªã±ãŒã·ã§ã³ã«å¯Ÿããããã€ãã®ã¿ãããæ¬ ããŠããŸãã
ããã°ã©ã å¯èœãªHTMLãçæããéã®åé¡ã®1ã€ã¯ã衚瀺ãããèŠçŽ ãããã°ã©ã ã³ãŒãããåé¢ããããšã§ããããã¯ãPEARã¯ã©ã¹ãéåžžã«æåããŠããããšã§ãã
ãã³ãã¬ãŒãã䜿çšãããšããã¶ã€ããŒã¯ããé åçã§è€éãªããŒãžãäœæãããã©ãŒã èŠçŽ ã®è¡šç€ºå Žæãæ£ç¢ºã«æ±ºå®ã§ããŸãã ãã¶ã€ããŒã¯HTMLãã¡ã€ã«ã䜿çšããããã°ã©ããŒã¯PHPã³ãŒããšPEARã¯ã©ã¹ã䜿çšããŸãããããã®1ã€ãå€æŽããŠãã2çªç®ã®ã¯ã©ã¹ãå€æŽããå¿ èŠã¯ãããŸããã
smartyãã³ãã¬ãŒãã¯HTML_QuickFormã§ã©ã®ããã«æ©èœããŸããïŒ
äžèšã®äŸã§ã¯ãè¡$ formâdisplayïŒïŒ; æšæºã®HTML_QuickFormsããžã¥ã¢ã©ã€ã¶ãŒãåŒã³åºããŸãã ãã®è¡ã眮ãæããããšã«ããã衚瀺ãããHTMLããã詳现ã«å¶åŸ¡ã§ããŸãã ãŸããã³ãŒãã2ã€ã®éšåïŒPHP / PEARã³ãŒããšãã³ãã¬ãŒããã¡ã€ã«èªäœïŒã«åå²ããããšãã§ããŸãã
ãã³ãã¬ãŒããã¡ã€ã«ã«ã¯ãHTMLã³ãŒããšããã€ãã®è¿œå ã¿ã°ãå«ãŸããŠããŸãã ãã®åçŽãªã¬ãã«ã§ã¯ããããã®ã¿ã°ã¯æ å ±ã衚瀺ããå Žæã§ãã ããžã¥ã¢ã©ã€ã¶ãŒã®åœ¹å²ã¯ããã©ãŒã ããŒã¿ãååŸãããã³ãã¬ãŒããªããžã§ã¯ãã§äœ¿çšã§ãã圢åŒã«è»¢éããããšã§ãã ãã³ãã¬ãŒããªããžã§ã¯ãã®åœ¹å²ã¯ããã³ãã¬ãŒããã¡ã€ã«ã解æããè¿œå ã®ã¿ã°ããã©ãŒã ã®ããŒã¿ã§çœ®ãæããããšã§ãã
ãã³ãã¬ãŒãã䜿çšãããã©ãŒã ã®äœæãšèŠèŠåã¯ãè€æ°ã®ã¹ãããããæãããã»ã¹ã§ãã
- ãã©ãŒã ã¯ã以åãšåãæ¹æ³ã§PEARã¯ã©ã¹ã䜿çšããŠäœæãããŸãã
- ãã³ãã¬ãŒããªããžã§ã¯ããäœæããã
- èŠèŠåãªããžã§ã¯ããäœæããã
- ããžã¥ã¢ã©ã€ã¶ãŒã¯åãã©ãŒã èŠçŽ ã®HTMLãã©ã°ã¡ã³ããçæãããããã®ãã©ã°ã¡ã³ãã¯ããã©ãŒã ã«é¢ããæ®ãã®æ å ±ãšãšãã«1ã€ã®å€§ããªé åã«åéãããŸãã
- ãã©ãŒã ããŒã¿ã®é åããã³ãã¬ãŒããªããžã§ã¯ãã«æž¡ããã
- 次ã«ããã³ãã¬ãŒããªããžã§ã¯ãã¯ãã³ãã¬ãŒããã¡ã€ã«ã解æããã¿ã°ãé åã®ããŒã¿ã§çœ®ãæããHTMLã衚瀺ããŸãã
4.ã·ã³ãã«ãªãã©ãŒã ãã³ãã¬ãŒãã
ç°¡åãªäŸ
ããã§ããã³ãã¬ãŒãã䜿çšããããã«äžèšã®äŸãå€æŽããŸãã ãã¡ã€ã«ã®å é ã«require_onceè¡ãå¿ èŠã§ãããŸããè¡$ formâdisplayïŒïŒ;ã眮ãæããŸãã ãã¿ãŒã³ã³ãŒãã ãã¹ãŠã®HTMLã³ãŒããåé€ããããšãã§ããŸãã çµæã¯ä»¥äžã®ãšããã§ãã
<?php require_once "HTML/QuickForm.php" ; require_once 'HTML/QuickForm/Renderer/ArraySmarty.php' ; require_once 'Smarty.class.php' ; $form = new HTML_QuickForm ( 'frmTest' , 'get' ) ; $form -> addElement ( 'header' , 'hdrTesting' , ' Smarty' ) ; $form -> addElement ( 'text' , 'txtFirstName' , '?' ) ; $form -> addElement ( 'text' , 'txtLastName' , '?' ) ; $form -> addElement ( 'text' , 'txtAge' , '?' ) ; $form -> addElement ( 'text' , 'txtTelephone' , ' ?' ) ; $form -> addElement ( 'reset' , 'btnClear' , '' ) ; $form -> addElement ( 'submit' , 'btnSubmit' , '' ) ; if ( $form -> validate ( ) ) { # , $form -> freeze ( ) ; } // $tpl =& new Smarty ; $tpl -> template_dir = '.' ; $tpl -> compile_dir = '/tmp' ; // $renderer =& new HTML_QuickForm_Renderer_ArraySmarty ( $tpl ) ; // HTML $form -> accept ( $renderer ) ; // $tpl -> assign ( 'form_data' , $renderer -> toArray ( ) ) ; // $tpl -> display ( 'smarty1.tpl' ) ; ?>
<?php require_once "HTML/QuickForm.php" ; require_once 'HTML/QuickForm/Renderer/ArraySmarty.php' ; require_once 'Smarty.class.php' ; $form = new HTML_QuickForm ( 'frmTest' , 'get' ) ; $form -> addElement ( 'header' , 'hdrTesting' , ' Smarty' ) ; $form -> addElement ( 'text' , 'txtFirstName' , '?' ) ; $form -> addElement ( 'text' , 'txtLastName' , '?' ) ; $form -> addElement ( 'text' , 'txtAge' , '?' ) ; $form -> addElement ( 'text' , 'txtTelephone' , ' ?' ) ; $form -> addElement ( 'reset' , 'btnClear' , '' ) ; $form -> addElement ( 'submit' , 'btnSubmit' , '' ) ; if ( $form -> validate ( ) ) { # , $form -> freeze ( ) ; } // $tpl =& new Smarty ; $tpl -> template_dir = '.' ; $tpl -> compile_dir = '/tmp' ; // $renderer =& new HTML_QuickForm_Renderer_ArraySmarty ( $tpl ) ; // HTML $form -> accept ( $renderer ) ; // $tpl -> assign ( 'form_data' , $renderer -> toArray ( ) ) ; // $tpl -> display ( 'smarty1.tpl' ) ; ?>
<?php require_once "HTML/QuickForm.php" ; require_once 'HTML/QuickForm/Renderer/ArraySmarty.php' ; require_once 'Smarty.class.php' ; $form = new HTML_QuickForm ( 'frmTest' , 'get' ) ; $form -> addElement ( 'header' , 'hdrTesting' , ' Smarty' ) ; $form -> addElement ( 'text' , 'txtFirstName' , '?' ) ; $form -> addElement ( 'text' , 'txtLastName' , '?' ) ; $form -> addElement ( 'text' , 'txtAge' , '?' ) ; $form -> addElement ( 'text' , 'txtTelephone' , ' ?' ) ; $form -> addElement ( 'reset' , 'btnClear' , '' ) ; $form -> addElement ( 'submit' , 'btnSubmit' , '' ) ; if ( $form -> validate ( ) ) { # , $form -> freeze ( ) ; } // $tpl =& new Smarty ; $tpl -> template_dir = '.' ; $tpl -> compile_dir = '/tmp' ; // $renderer =& new HTML_QuickForm_Renderer_ArraySmarty ( $tpl ) ; // HTML $form -> accept ( $renderer ) ; // $tpl -> assign ( 'form_data' , $renderer -> toArray ( ) ) ; // $tpl -> display ( 'smarty1.tpl' ) ; ?>
<?php require_once "HTML/QuickForm.php" ; require_once 'HTML/QuickForm/Renderer/ArraySmarty.php' ; require_once 'Smarty.class.php' ; $form = new HTML_QuickForm ( 'frmTest' , 'get' ) ; $form -> addElement ( 'header' , 'hdrTesting' , ' Smarty' ) ; $form -> addElement ( 'text' , 'txtFirstName' , '?' ) ; $form -> addElement ( 'text' , 'txtLastName' , '?' ) ; $form -> addElement ( 'text' , 'txtAge' , '?' ) ; $form -> addElement ( 'text' , 'txtTelephone' , ' ?' ) ; $form -> addElement ( 'reset' , 'btnClear' , '' ) ; $form -> addElement ( 'submit' , 'btnSubmit' , '' ) ; if ( $form -> validate ( ) ) { # , $form -> freeze ( ) ; } // $tpl =& new Smarty ; $tpl -> template_dir = '.' ; $tpl -> compile_dir = '/tmp' ; // $renderer =& new HTML_QuickForm_Renderer_ArraySmarty ( $tpl ) ; // HTML $form -> accept ( $renderer ) ; // $tpl -> assign ( 'form_data' , $renderer -> toArray ( ) ) ; // $tpl -> display ( 'smarty1.tpl' ) ; ?>
<?php require_once "HTML/QuickForm.php" ; require_once 'HTML/QuickForm/Renderer/ArraySmarty.php' ; require_once 'Smarty.class.php' ; $form = new HTML_QuickForm ( 'frmTest' , 'get' ) ; $form -> addElement ( 'header' , 'hdrTesting' , ' Smarty' ) ; $form -> addElement ( 'text' , 'txtFirstName' , '?' ) ; $form -> addElement ( 'text' , 'txtLastName' , '?' ) ; $form -> addElement ( 'text' , 'txtAge' , '?' ) ; $form -> addElement ( 'text' , 'txtTelephone' , ' ?' ) ; $form -> addElement ( 'reset' , 'btnClear' , '' ) ; $form -> addElement ( 'submit' , 'btnSubmit' , '' ) ; if ( $form -> validate ( ) ) { # , $form -> freeze ( ) ; } // $tpl =& new Smarty ; $tpl -> template_dir = '.' ; $tpl -> compile_dir = '/tmp' ; // $renderer =& new HTML_QuickForm_Renderer_ArraySmarty ( $tpl ) ; // HTML $form -> accept ( $renderer ) ; // $tpl -> assign ( 'form_data' , $renderer -> toArray ( ) ) ; // $tpl -> display ( 'smarty1.tpl' ) ; ?>
<?php require_once "HTML/QuickForm.php" ; require_once 'HTML/QuickForm/Renderer/ArraySmarty.php' ; require_once 'Smarty.class.php' ; $form = new HTML_QuickForm ( 'frmTest' , 'get' ) ; $form -> addElement ( 'header' , 'hdrTesting' , ' Smarty' ) ; $form -> addElement ( 'text' , 'txtFirstName' , '?' ) ; $form -> addElement ( 'text' , 'txtLastName' , '?' ) ; $form -> addElement ( 'text' , 'txtAge' , '?' ) ; $form -> addElement ( 'text' , 'txtTelephone' , ' ?' ) ; $form -> addElement ( 'reset' , 'btnClear' , '' ) ; $form -> addElement ( 'submit' , 'btnSubmit' , '' ) ; if ( $form -> validate ( ) ) { # , $form -> freeze ( ) ; } // $tpl =& new Smarty ; $tpl -> template_dir = '.' ; $tpl -> compile_dir = '/tmp' ; // $renderer =& new HTML_QuickForm_Renderer_ArraySmarty ( $tpl ) ; // HTML $form -> accept ( $renderer ) ; // $tpl -> assign ( 'form_data' , $renderer -> toArray ( ) ) ; // $tpl -> display ( 'smarty1.tpl' ) ; ?>
<?php require_once "HTML/QuickForm.php" ; require_once 'HTML/QuickForm/Renderer/ArraySmarty.php' ; require_once 'Smarty.class.php' ; $form = new HTML_QuickForm ( 'frmTest' , 'get' ) ; $form -> addElement ( 'header' , 'hdrTesting' , ' Smarty' ) ; $form -> addElement ( 'text' , 'txtFirstName' , '?' ) ; $form -> addElement ( 'text' , 'txtLastName' , '?' ) ; $form -> addElement ( 'text' , 'txtAge' , '?' ) ; $form -> addElement ( 'text' , 'txtTelephone' , ' ?' ) ; $form -> addElement ( 'reset' , 'btnClear' , '' ) ; $form -> addElement ( 'submit' , 'btnSubmit' , '' ) ; if ( $form -> validate ( ) ) { # , $form -> freeze ( ) ; } // $tpl =& new Smarty ; $tpl -> template_dir = '.' ; $tpl -> compile_dir = '/tmp' ; // $renderer =& new HTML_QuickForm_Renderer_ArraySmarty ( $tpl ) ; // HTML $form -> accept ( $renderer ) ; // $tpl -> assign ( 'form_data' , $renderer -> toArray ( ) ) ; // $tpl -> display ( 'smarty1.tpl' ) ; ?>
<?php require_once "HTML/QuickForm.php" ; require_once 'HTML/QuickForm/Renderer/ArraySmarty.php' ; require_once 'Smarty.class.php' ; $form = new HTML_QuickForm ( 'frmTest' , 'get' ) ; $form -> addElement ( 'header' , 'hdrTesting' , ' Smarty' ) ; $form -> addElement ( 'text' , 'txtFirstName' , '?' ) ; $form -> addElement ( 'text' , 'txtLastName' , '?' ) ; $form -> addElement ( 'text' , 'txtAge' , '?' ) ; $form -> addElement ( 'text' , 'txtTelephone' , ' ?' ) ; $form -> addElement ( 'reset' , 'btnClear' , '' ) ; $form -> addElement ( 'submit' , 'btnSubmit' , '' ) ; if ( $form -> validate ( ) ) { # , $form -> freeze ( ) ; } // $tpl =& new Smarty ; $tpl -> template_dir = '.' ; $tpl -> compile_dir = '/tmp' ; // $renderer =& new HTML_QuickForm_Renderer_ArraySmarty ( $tpl ) ; // HTML $form -> accept ( $renderer ) ; // $tpl -> assign ( 'form_data' , $renderer -> toArray ( ) ) ; // $tpl -> display ( 'smarty1.tpl' ) ; ?>
<?php require_once "HTML/QuickForm.php" ; require_once 'HTML/QuickForm/Renderer/ArraySmarty.php' ; require_once 'Smarty.class.php' ; $form = new HTML_QuickForm ( 'frmTest' , 'get' ) ; $form -> addElement ( 'header' , 'hdrTesting' , ' Smarty' ) ; $form -> addElement ( 'text' , 'txtFirstName' , '?' ) ; $form -> addElement ( 'text' , 'txtLastName' , '?' ) ; $form -> addElement ( 'text' , 'txtAge' , '?' ) ; $form -> addElement ( 'text' , 'txtTelephone' , ' ?' ) ; $form -> addElement ( 'reset' , 'btnClear' , '' ) ; $form -> addElement ( 'submit' , 'btnSubmit' , '' ) ; if ( $form -> validate ( ) ) { # , $form -> freeze ( ) ; } // $tpl =& new Smarty ; $tpl -> template_dir = '.' ; $tpl -> compile_dir = '/tmp' ; // $renderer =& new HTML_QuickForm_Renderer_ArraySmarty ( $tpl ) ; // HTML $form -> accept ( $renderer ) ; // $tpl -> assign ( 'form_data' , $renderer -> toArray ( ) ) ; // $tpl -> display ( 'smarty1.tpl' ) ; ?>
<?php require_once "HTML/QuickForm.php" ; require_once 'HTML/QuickForm/Renderer/ArraySmarty.php' ; require_once 'Smarty.class.php' ; $form = new HTML_QuickForm ( 'frmTest' , 'get' ) ; $form -> addElement ( 'header' , 'hdrTesting' , ' Smarty' ) ; $form -> addElement ( 'text' , 'txtFirstName' , '?' ) ; $form -> addElement ( 'text' , 'txtLastName' , '?' ) ; $form -> addElement ( 'text' , 'txtAge' , '?' ) ; $form -> addElement ( 'text' , 'txtTelephone' , ' ?' ) ; $form -> addElement ( 'reset' , 'btnClear' , '' ) ; $form -> addElement ( 'submit' , 'btnSubmit' , '' ) ; if ( $form -> validate ( ) ) { # , $form -> freeze ( ) ; } // $tpl =& new Smarty ; $tpl -> template_dir = '.' ; $tpl -> compile_dir = '/tmp' ; // $renderer =& new HTML_QuickForm_Renderer_ArraySmarty ( $tpl ) ; // HTML $form -> accept ( $renderer ) ; // $tpl -> assign ( 'form_data' , $renderer -> toArray ( ) ) ; // $tpl -> display ( 'smarty1.tpl' ) ; ?>
<?php require_once "HTML/QuickForm.php" ; require_once 'HTML/QuickForm/Renderer/ArraySmarty.php' ; require_once 'Smarty.class.php' ; $form = new HTML_QuickForm ( 'frmTest' , 'get' ) ; $form -> addElement ( 'header' , 'hdrTesting' , ' Smarty' ) ; $form -> addElement ( 'text' , 'txtFirstName' , '?' ) ; $form -> addElement ( 'text' , 'txtLastName' , '?' ) ; $form -> addElement ( 'text' , 'txtAge' , '?' ) ; $form -> addElement ( 'text' , 'txtTelephone' , ' ?' ) ; $form -> addElement ( 'reset' , 'btnClear' , '' ) ; $form -> addElement ( 'submit' , 'btnSubmit' , '' ) ; if ( $form -> validate ( ) ) { # , $form -> freeze ( ) ; } // $tpl =& new Smarty ; $tpl -> template_dir = '.' ; $tpl -> compile_dir = '/tmp' ; // $renderer =& new HTML_QuickForm_Renderer_ArraySmarty ( $tpl ) ; // HTML $form -> accept ( $renderer ) ; // $tpl -> assign ( 'form_data' , $renderer -> toArray ( ) ) ; // $tpl -> display ( 'smarty1.tpl' ) ; ?>
<?php require_once "HTML/QuickForm.php" ; require_once 'HTML/QuickForm/Renderer/ArraySmarty.php' ; require_once 'Smarty.class.php' ; $form = new HTML_QuickForm ( 'frmTest' , 'get' ) ; $form -> addElement ( 'header' , 'hdrTesting' , ' Smarty' ) ; $form -> addElement ( 'text' , 'txtFirstName' , '?' ) ; $form -> addElement ( 'text' , 'txtLastName' , '?' ) ; $form -> addElement ( 'text' , 'txtAge' , '?' ) ; $form -> addElement ( 'text' , 'txtTelephone' , ' ?' ) ; $form -> addElement ( 'reset' , 'btnClear' , '' ) ; $form -> addElement ( 'submit' , 'btnSubmit' , '' ) ; if ( $form -> validate ( ) ) { # , $form -> freeze ( ) ; } // $tpl =& new Smarty ; $tpl -> template_dir = '.' ; $tpl -> compile_dir = '/tmp' ; // $renderer =& new HTML_QuickForm_Renderer_ArraySmarty ( $tpl ) ; // HTML $form -> accept ( $renderer ) ; // $tpl -> assign ( 'form_data' , $renderer -> toArray ( ) ) ; // $tpl -> display ( 'smarty1.tpl' ) ; ?>
<?php require_once "HTML/QuickForm.php" ; require_once 'HTML/QuickForm/Renderer/ArraySmarty.php' ; require_once 'Smarty.class.php' ; $form = new HTML_QuickForm ( 'frmTest' , 'get' ) ; $form -> addElement ( 'header' , 'hdrTesting' , ' Smarty' ) ; $form -> addElement ( 'text' , 'txtFirstName' , '?' ) ; $form -> addElement ( 'text' , 'txtLastName' , '?' ) ; $form -> addElement ( 'text' , 'txtAge' , '?' ) ; $form -> addElement ( 'text' , 'txtTelephone' , ' ?' ) ; $form -> addElement ( 'reset' , 'btnClear' , '' ) ; $form -> addElement ( 'submit' , 'btnSubmit' , '' ) ; if ( $form -> validate ( ) ) { # , $form -> freeze ( ) ; } // $tpl =& new Smarty ; $tpl -> template_dir = '.' ; $tpl -> compile_dir = '/tmp' ; // $renderer =& new HTML_QuickForm_Renderer_ArraySmarty ( $tpl ) ; // HTML $form -> accept ( $renderer ) ; // $tpl -> assign ( 'form_data' , $renderer -> toArray ( ) ) ; // $tpl -> display ( 'smarty1.tpl' ) ; ?>
<?php require_once "HTML/QuickForm.php" ; require_once 'HTML/QuickForm/Renderer/ArraySmarty.php' ; require_once 'Smarty.class.php' ; $form = new HTML_QuickForm ( 'frmTest' , 'get' ) ; $form -> addElement ( 'header' , 'hdrTesting' , ' Smarty' ) ; $form -> addElement ( 'text' , 'txtFirstName' , '?' ) ; $form -> addElement ( 'text' , 'txtLastName' , '?' ) ; $form -> addElement ( 'text' , 'txtAge' , '?' ) ; $form -> addElement ( 'text' , 'txtTelephone' , ' ?' ) ; $form -> addElement ( 'reset' , 'btnClear' , '' ) ; $form -> addElement ( 'submit' , 'btnSubmit' , '' ) ; if ( $form -> validate ( ) ) { # , $form -> freeze ( ) ; } // $tpl =& new Smarty ; $tpl -> template_dir = '.' ; $tpl -> compile_dir = '/tmp' ; // $renderer =& new HTML_QuickForm_Renderer_ArraySmarty ( $tpl ) ; // HTML $form -> accept ( $renderer ) ; // $tpl -> assign ( 'form_data' , $renderer -> toArray ( ) ) ; // $tpl -> display ( 'smarty1.tpl' ) ; ?>
<?php require_once "HTML/QuickForm.php" ; require_once 'HTML/QuickForm/Renderer/ArraySmarty.php' ; require_once 'Smarty.class.php' ; $form = new HTML_QuickForm ( 'frmTest' , 'get' ) ; $form -> addElement ( 'header' , 'hdrTesting' , ' Smarty' ) ; $form -> addElement ( 'text' , 'txtFirstName' , '?' ) ; $form -> addElement ( 'text' , 'txtLastName' , '?' ) ; $form -> addElement ( 'text' , 'txtAge' , '?' ) ; $form -> addElement ( 'text' , 'txtTelephone' , ' ?' ) ; $form -> addElement ( 'reset' , 'btnClear' , '' ) ; $form -> addElement ( 'submit' , 'btnSubmit' , '' ) ; if ( $form -> validate ( ) ) { # , $form -> freeze ( ) ; } // $tpl =& new Smarty ; $tpl -> template_dir = '.' ; $tpl -> compile_dir = '/tmp' ; // $renderer =& new HTML_QuickForm_Renderer_ArraySmarty ( $tpl ) ; // HTML $form -> accept ( $renderer ) ; // $tpl -> assign ( 'form_data' , $renderer -> toArray ( ) ) ; // $tpl -> display ( 'smarty1.tpl' ) ; ?>
<?php require_once "HTML/QuickForm.php" ; require_once 'HTML/QuickForm/Renderer/ArraySmarty.php' ; require_once 'Smarty.class.php' ; $form = new HTML_QuickForm ( 'frmTest' , 'get' ) ; $form -> addElement ( 'header' , 'hdrTesting' , ' Smarty' ) ; $form -> addElement ( 'text' , 'txtFirstName' , '?' ) ; $form -> addElement ( 'text' , 'txtLastName' , '?' ) ; $form -> addElement ( 'text' , 'txtAge' , '?' ) ; $form -> addElement ( 'text' , 'txtTelephone' , ' ?' ) ; $form -> addElement ( 'reset' , 'btnClear' , '' ) ; $form -> addElement ( 'submit' , 'btnSubmit' , '' ) ; if ( $form -> validate ( ) ) { # , $form -> freeze ( ) ; } // $tpl =& new Smarty ; $tpl -> template_dir = '.' ; $tpl -> compile_dir = '/tmp' ; // $renderer =& new HTML_QuickForm_Renderer_ArraySmarty ( $tpl ) ; // HTML $form -> accept ( $renderer ) ; // $tpl -> assign ( 'form_data' , $renderer -> toArray ( ) ) ; // $tpl -> display ( 'smarty1.tpl' ) ; ?>
<?php require_once "HTML/QuickForm.php" ; require_once 'HTML/QuickForm/Renderer/ArraySmarty.php' ; require_once 'Smarty.class.php' ; $form = new HTML_QuickForm ( 'frmTest' , 'get' ) ; $form -> addElement ( 'header' , 'hdrTesting' , ' Smarty' ) ; $form -> addElement ( 'text' , 'txtFirstName' , '?' ) ; $form -> addElement ( 'text' , 'txtLastName' , '?' ) ; $form -> addElement ( 'text' , 'txtAge' , '?' ) ; $form -> addElement ( 'text' , 'txtTelephone' , ' ?' ) ; $form -> addElement ( 'reset' , 'btnClear' , '' ) ; $form -> addElement ( 'submit' , 'btnSubmit' , '' ) ; if ( $form -> validate ( ) ) { # , $form -> freeze ( ) ; } // $tpl =& new Smarty ; $tpl -> template_dir = '.' ; $tpl -> compile_dir = '/tmp' ; // $renderer =& new HTML_QuickForm_Renderer_ArraySmarty ( $tpl ) ; // HTML $form -> accept ( $renderer ) ; // $tpl -> assign ( 'form_data' , $renderer -> toArray ( ) ) ; // $tpl -> display ( 'smarty1.tpl' ) ; ?>
<?php require_once "HTML/QuickForm.php" ; require_once 'HTML/QuickForm/Renderer/ArraySmarty.php' ; require_once 'Smarty.class.php' ; $form = new HTML_QuickForm ( 'frmTest' , 'get' ) ; $form -> addElement ( 'header' , 'hdrTesting' , ' Smarty' ) ; $form -> addElement ( 'text' , 'txtFirstName' , '?' ) ; $form -> addElement ( 'text' , 'txtLastName' , '?' ) ; $form -> addElement ( 'text' , 'txtAge' , '?' ) ; $form -> addElement ( 'text' , 'txtTelephone' , ' ?' ) ; $form -> addElement ( 'reset' , 'btnClear' , '' ) ; $form -> addElement ( 'submit' , 'btnSubmit' , '' ) ; if ( $form -> validate ( ) ) { # , $form -> freeze ( ) ; } // $tpl =& new Smarty ; $tpl -> template_dir = '.' ; $tpl -> compile_dir = '/tmp' ; // $renderer =& new HTML_QuickForm_Renderer_ArraySmarty ( $tpl ) ; // HTML $form -> accept ( $renderer ) ; // $tpl -> assign ( 'form_data' , $renderer -> toArray ( ) ) ; // $tpl -> display ( 'smarty1.tpl' ) ; ?>
<?php require_once "HTML/QuickForm.php" ; require_once 'HTML/QuickForm/Renderer/ArraySmarty.php' ; require_once 'Smarty.class.php' ; $form = new HTML_QuickForm ( 'frmTest' , 'get' ) ; $form -> addElement ( 'header' , 'hdrTesting' , ' Smarty' ) ; $form -> addElement ( 'text' , 'txtFirstName' , '?' ) ; $form -> addElement ( 'text' , 'txtLastName' , '?' ) ; $form -> addElement ( 'text' , 'txtAge' , '?' ) ; $form -> addElement ( 'text' , 'txtTelephone' , ' ?' ) ; $form -> addElement ( 'reset' , 'btnClear' , '' ) ; $form -> addElement ( 'submit' , 'btnSubmit' , '' ) ; if ( $form -> validate ( ) ) { # , $form -> freeze ( ) ; } // $tpl =& new Smarty ; $tpl -> template_dir = '.' ; $tpl -> compile_dir = '/tmp' ; // $renderer =& new HTML_QuickForm_Renderer_ArraySmarty ( $tpl ) ; // HTML $form -> accept ( $renderer ) ; // $tpl -> assign ( 'form_data' , $renderer -> toArray ( ) ) ; // $tpl -> display ( 'smarty1.tpl' ) ; ?>
<?php require_once "HTML/QuickForm.php" ; require_once 'HTML/QuickForm/Renderer/ArraySmarty.php' ; require_once 'Smarty.class.php' ; $form = new HTML_QuickForm ( 'frmTest' , 'get' ) ; $form -> addElement ( 'header' , 'hdrTesting' , ' Smarty' ) ; $form -> addElement ( 'text' , 'txtFirstName' , '?' ) ; $form -> addElement ( 'text' , 'txtLastName' , '?' ) ; $form -> addElement ( 'text' , 'txtAge' , '?' ) ; $form -> addElement ( 'text' , 'txtTelephone' , ' ?' ) ; $form -> addElement ( 'reset' , 'btnClear' , '' ) ; $form -> addElement ( 'submit' , 'btnSubmit' , '' ) ; if ( $form -> validate ( ) ) { # , $form -> freeze ( ) ; } // $tpl =& new Smarty ; $tpl -> template_dir = '.' ; $tpl -> compile_dir = '/tmp' ; // $renderer =& new HTML_QuickForm_Renderer_ArraySmarty ( $tpl ) ; // HTML $form -> accept ( $renderer ) ; // $tpl -> assign ( 'form_data' , $renderer -> toArray ( ) ) ; // $tpl -> display ( 'smarty1.tpl' ) ; ?>
<?php require_once "HTML/QuickForm.php" ; require_once 'HTML/QuickForm/Renderer/ArraySmarty.php' ; require_once 'Smarty.class.php' ; $form = new HTML_QuickForm ( 'frmTest' , 'get' ) ; $form -> addElement ( 'header' , 'hdrTesting' , ' Smarty' ) ; $form -> addElement ( 'text' , 'txtFirstName' , '?' ) ; $form -> addElement ( 'text' , 'txtLastName' , '?' ) ; $form -> addElement ( 'text' , 'txtAge' , '?' ) ; $form -> addElement ( 'text' , 'txtTelephone' , ' ?' ) ; $form -> addElement ( 'reset' , 'btnClear' , '' ) ; $form -> addElement ( 'submit' , 'btnSubmit' , '' ) ; if ( $form -> validate ( ) ) { # , $form -> freeze ( ) ; } // $tpl =& new Smarty ; $tpl -> template_dir = '.' ; $tpl -> compile_dir = '/tmp' ; // $renderer =& new HTML_QuickForm_Renderer_ArraySmarty ( $tpl ) ; // HTML $form -> accept ( $renderer ) ; // $tpl -> assign ( 'form_data' , $renderer -> toArray ( ) ) ; // $tpl -> display ( 'smarty1.tpl' ) ; ?>
<?php require_once "HTML/QuickForm.php" ; require_once 'HTML/QuickForm/Renderer/ArraySmarty.php' ; require_once 'Smarty.class.php' ; $form = new HTML_QuickForm ( 'frmTest' , 'get' ) ; $form -> addElement ( 'header' , 'hdrTesting' , ' Smarty' ) ; $form -> addElement ( 'text' , 'txtFirstName' , '?' ) ; $form -> addElement ( 'text' , 'txtLastName' , '?' ) ; $form -> addElement ( 'text' , 'txtAge' , '?' ) ; $form -> addElement ( 'text' , 'txtTelephone' , ' ?' ) ; $form -> addElement ( 'reset' , 'btnClear' , '' ) ; $form -> addElement ( 'submit' , 'btnSubmit' , '' ) ; if ( $form -> validate ( ) ) { # , $form -> freeze ( ) ; } // $tpl =& new Smarty ; $tpl -> template_dir = '.' ; $tpl -> compile_dir = '/tmp' ; // $renderer =& new HTML_QuickForm_Renderer_ArraySmarty ( $tpl ) ; // HTML $form -> accept ( $renderer ) ; // $tpl -> assign ( 'form_data' , $renderer -> toArray ( ) ) ; // $tpl -> display ( 'smarty1.tpl' ) ; ?>
<?php require_once "HTML/QuickForm.php" ; require_once 'HTML/QuickForm/Renderer/ArraySmarty.php' ; require_once 'Smarty.class.php' ; $form = new HTML_QuickForm ( 'frmTest' , 'get' ) ; $form -> addElement ( 'header' , 'hdrTesting' , ' Smarty' ) ; $form -> addElement ( 'text' , 'txtFirstName' , '?' ) ; $form -> addElement ( 'text' , 'txtLastName' , '?' ) ; $form -> addElement ( 'text' , 'txtAge' , '?' ) ; $form -> addElement ( 'text' , 'txtTelephone' , ' ?' ) ; $form -> addElement ( 'reset' , 'btnClear' , '' ) ; $form -> addElement ( 'submit' , 'btnSubmit' , '' ) ; if ( $form -> validate ( ) ) { # , $form -> freeze ( ) ; } // $tpl =& new Smarty ; $tpl -> template_dir = '.' ; $tpl -> compile_dir = '/tmp' ; // $renderer =& new HTML_QuickForm_Renderer_ArraySmarty ( $tpl ) ; // HTML $form -> accept ( $renderer ) ; // $tpl -> assign ( 'form_data' , $renderer -> toArray ( ) ) ; // $tpl -> display ( 'smarty1.tpl' ) ; ?>
<?php require_once "HTML/QuickForm.php" ; require_once 'HTML/QuickForm/Renderer/ArraySmarty.php' ; require_once 'Smarty.class.php' ; $form = new HTML_QuickForm ( 'frmTest' , 'get' ) ; $form -> addElement ( 'header' , 'hdrTesting' , ' Smarty' ) ; $form -> addElement ( 'text' , 'txtFirstName' , '?' ) ; $form -> addElement ( 'text' , 'txtLastName' , '?' ) ; $form -> addElement ( 'text' , 'txtAge' , '?' ) ; $form -> addElement ( 'text' , 'txtTelephone' , ' ?' ) ; $form -> addElement ( 'reset' , 'btnClear' , '' ) ; $form -> addElement ( 'submit' , 'btnSubmit' , '' ) ; if ( $form -> validate ( ) ) { # , $form -> freeze ( ) ; } // $tpl =& new Smarty ; $tpl -> template_dir = '.' ; $tpl -> compile_dir = '/tmp' ; // $renderer =& new HTML_QuickForm_Renderer_ArraySmarty ( $tpl ) ; // HTML $form -> accept ( $renderer ) ; // $tpl -> assign ( 'form_data' , $renderer -> toArray ( ) ) ; // $tpl -> display ( 'smarty1.tpl' ) ; ?>
<?php require_once "HTML/QuickForm.php" ; require_once 'HTML/QuickForm/Renderer/ArraySmarty.php' ; require_once 'Smarty.class.php' ; $form = new HTML_QuickForm ( 'frmTest' , 'get' ) ; $form -> addElement ( 'header' , 'hdrTesting' , ' Smarty' ) ; $form -> addElement ( 'text' , 'txtFirstName' , '?' ) ; $form -> addElement ( 'text' , 'txtLastName' , '?' ) ; $form -> addElement ( 'text' , 'txtAge' , '?' ) ; $form -> addElement ( 'text' , 'txtTelephone' , ' ?' ) ; $form -> addElement ( 'reset' , 'btnClear' , '' ) ; $form -> addElement ( 'submit' , 'btnSubmit' , '' ) ; if ( $form -> validate ( ) ) { # , $form -> freeze ( ) ; } // $tpl =& new Smarty ; $tpl -> template_dir = '.' ; $tpl -> compile_dir = '/tmp' ; // $renderer =& new HTML_QuickForm_Renderer_ArraySmarty ( $tpl ) ; // HTML $form -> accept ( $renderer ) ; // $tpl -> assign ( 'form_data' , $renderer -> toArray ( ) ) ; // $tpl -> display ( 'smarty1.tpl' ) ; ?>
<?php require_once "HTML/QuickForm.php" ; require_once 'HTML/QuickForm/Renderer/ArraySmarty.php' ; require_once 'Smarty.class.php' ; $form = new HTML_QuickForm ( 'frmTest' , 'get' ) ; $form -> addElement ( 'header' , 'hdrTesting' , ' Smarty' ) ; $form -> addElement ( 'text' , 'txtFirstName' , '?' ) ; $form -> addElement ( 'text' , 'txtLastName' , '?' ) ; $form -> addElement ( 'text' , 'txtAge' , '?' ) ; $form -> addElement ( 'text' , 'txtTelephone' , ' ?' ) ; $form -> addElement ( 'reset' , 'btnClear' , '' ) ; $form -> addElement ( 'submit' , 'btnSubmit' , '' ) ; if ( $form -> validate ( ) ) { # , $form -> freeze ( ) ; } // $tpl =& new Smarty ; $tpl -> template_dir = '.' ; $tpl -> compile_dir = '/tmp' ; // $renderer =& new HTML_QuickForm_Renderer_ArraySmarty ( $tpl ) ; // HTML $form -> accept ( $renderer ) ; // $tpl -> assign ( 'form_data' , $renderer -> toArray ( ) ) ; // $tpl -> display ( 'smarty1.tpl' ) ; ?>
<?php require_once "HTML/QuickForm.php" ; require_once 'HTML/QuickForm/Renderer/ArraySmarty.php' ; require_once 'Smarty.class.php' ; $form = new HTML_QuickForm ( 'frmTest' , 'get' ) ; $form -> addElement ( 'header' , 'hdrTesting' , ' Smarty' ) ; $form -> addElement ( 'text' , 'txtFirstName' , '?' ) ; $form -> addElement ( 'text' , 'txtLastName' , '?' ) ; $form -> addElement ( 'text' , 'txtAge' , '?' ) ; $form -> addElement ( 'text' , 'txtTelephone' , ' ?' ) ; $form -> addElement ( 'reset' , 'btnClear' , '' ) ; $form -> addElement ( 'submit' , 'btnSubmit' , '' ) ; if ( $form -> validate ( ) ) { # , $form -> freeze ( ) ; } // $tpl =& new Smarty ; $tpl -> template_dir = '.' ; $tpl -> compile_dir = '/tmp' ; // $renderer =& new HTML_QuickForm_Renderer_ArraySmarty ( $tpl ) ; // HTML $form -> accept ( $renderer ) ; // $tpl -> assign ( 'form_data' , $renderer -> toArray ( ) ) ; // $tpl -> display ( 'smarty1.tpl' ) ; ?>
<?php require_once "HTML/QuickForm.php" ; require_once 'HTML/QuickForm/Renderer/ArraySmarty.php' ; require_once 'Smarty.class.php' ; $form = new HTML_QuickForm ( 'frmTest' , 'get' ) ; $form -> addElement ( 'header' , 'hdrTesting' , ' Smarty' ) ; $form -> addElement ( 'text' , 'txtFirstName' , '?' ) ; $form -> addElement ( 'text' , 'txtLastName' , '?' ) ; $form -> addElement ( 'text' , 'txtAge' , '?' ) ; $form -> addElement ( 'text' , 'txtTelephone' , ' ?' ) ; $form -> addElement ( 'reset' , 'btnClear' , '' ) ; $form -> addElement ( 'submit' , 'btnSubmit' , '' ) ; if ( $form -> validate ( ) ) { # , $form -> freeze ( ) ; } // $tpl =& new Smarty ; $tpl -> template_dir = '.' ; $tpl -> compile_dir = '/tmp' ; // $renderer =& new HTML_QuickForm_Renderer_ArraySmarty ( $tpl ) ; // HTML $form -> accept ( $renderer ) ; // $tpl -> assign ( 'form_data' , $renderer -> toArray ( ) ) ; // $tpl -> display ( 'smarty1.tpl' ) ; ?>
<?php require_once "HTML/QuickForm.php" ; require_once 'HTML/QuickForm/Renderer/ArraySmarty.php' ; require_once 'Smarty.class.php' ; $form = new HTML_QuickForm ( 'frmTest' , 'get' ) ; $form -> addElement ( 'header' , 'hdrTesting' , ' Smarty' ) ; $form -> addElement ( 'text' , 'txtFirstName' , '?' ) ; $form -> addElement ( 'text' , 'txtLastName' , '?' ) ; $form -> addElement ( 'text' , 'txtAge' , '?' ) ; $form -> addElement ( 'text' , 'txtTelephone' , ' ?' ) ; $form -> addElement ( 'reset' , 'btnClear' , '' ) ; $form -> addElement ( 'submit' , 'btnSubmit' , '' ) ; if ( $form -> validate ( ) ) { # , $form -> freeze ( ) ; } // $tpl =& new Smarty ; $tpl -> template_dir = '.' ; $tpl -> compile_dir = '/tmp' ; // $renderer =& new HTML_QuickForm_Renderer_ArraySmarty ( $tpl ) ; // HTML $form -> accept ( $renderer ) ; // $tpl -> assign ( 'form_data' , $renderer -> toArray ( ) ) ; // $tpl -> display ( 'smarty1.tpl' ) ; ?>
ãŸãã以äžã«ç€ºããã³ãã¬ãŒããã¡ã€ã«ãå¿ èŠã§ãã ãã¡ã€ã«ã¯ãäžèšã®PHPãã¡ã€ã«ãšåããã©ã«ããŒã«é 眮ããå¿ èŠããããŸãã

äžèšã®ã³ãŒãã§ç€ºããããã©ãŒã ã¯ãæé«ã®ãã¶ã€ã³ã®ãã¬ãã¢ã ã確å®ã«åãåãããšã¯ãããŸããããåã®äŸããããã£ãšè¯ãèŠããŸãã
åé¡ãçºçããå Žåã¯ã次ã確èªããŠãã ããã
- ãã¡ã€ã«åã¯ãã®èšäºã«èšèŒãããŠãããã®ãšäžèŽããŸããïŒ
- äž¡æ¹ã®ãã¡ã€ã«ã¯åããã©ã«ããŒã«ãããŸããïŒ
- WebãµãŒããŒããã»ã¹ã«èªã¿åãæš©éããããŸããïŒ
- WebãµãŒããŒããã»ã¹ã«ã¯ã/ tmpãã©ã«ããŒãžã®æžã蟌ã¿æš©éããããŸããïŒ
ã¹ããããã€ã¹ãããïŒPHPãœãŒã¹ã³ãŒã
æåã®ããŒãžã§ã³ãšæ¯èŒããŠã次ã®éãã«æ³šæããŠãã ããã
- æåã®ããŒãžã§ã³ãšã¯ç°ãªãããã©ãŒã ã¯2ã€ã®åã§è¡šãããŸããã
- ããŒãžã®äžçªäžã«ã¯éçãªèäœæš©æ å ±ãããã
- PHPãã¡ã€ã«ã«ã¯ãPHPã³ãŒãã®ã¿ãå«ãŸããŠããŸãã
PHPã³ãŒãã§å§ãŸããã¡ã€ã«ãåæããŸãããã è¿œå ã®require_onceè¡ã«å ããŠãSmartyãã³ãã¬ãŒããªããžã§ã¯ããå°å ¥ãããšãã«æåã®å€æŽãè¡ãããŸããã
- //ãã³ãã¬ãŒããªããžã§ã¯ããäœæããŸã
- $ tpl =ïŒ new Smarty ;
- $ tpl- > template_dir = 'ã' ;
- $ tpl- > compile_dir = '/ tmp' ;
åæååŸããã³ãã¬ãŒããã¡ã€ã«ïŒç¹å®ã®å Žåãããã¯åããã©ã«ããŒïŒãèŠã€ããããšãã§ãããã³ãã¬ãŒããªããžã§ã¯ããšãã³ã³ãã€ã«æžã¿ããŒãžã§ã³ãããŒããããã©ã«ããŒïŒç¹å®ã®å Žåãããã¯/ tmpãã©ã«ããŒïŒãèŠæ±ããŸãã WebãµãŒããŒããã»ã¹ã«ãã³ãã¬ãŒããã©ã«ããŒãžã®èªã¿åãæš©éãšãã³ã³ãã€ã«æžã¿ããŒãžã§ã³ã®ãã©ã«ããŒãžã®æžã蟌ã¿æš©éãããå Žåãä»»æã®ãã©ã«ããŒã䜿çšã§ããŸãã
次ã«ããã³ãã¬ãŒããªããžã§ã¯ãããã©ã¡ãŒã¿ãŒãšããŠæž¡ãããšã§ãããžã¥ã¢ã©ã€ã¶ãŒãåæåããŸãã
- //èŠèŠåãªããžã§ã¯ããäœæããŸã
- $ renderer =ïŒ new HTML_QuickForm_Renderer_ArraySmarty ïŒ $ tpl ïŒ ;
次ã®ã¹ãããã¯ãåèŠçŽ ã®ãã©ãŒã æ å ±ãšHTMLãã©ã°ã¡ã³ããå«ãé åãäœæããããšã§ãã ããã¯ã次ã®è¡ã§å®è¡ãããŸãã
- //ãã©ãŒã ã®HTMLãäœæããŸã
- $ form- > accept ïŒ $ renderer ïŒ ;
次ã®ã¹ãããã§ã¯ãããŒã¿é åããã³ãã¬ãŒãã«æž¡ããŸãã
- //ãã©ãŒã ããŒã¿ãé åã«å²ãåœãŠãŸã
- $ tpl- > assign ïŒ 'form_data' ã $ renderer- > toArray ïŒ ïŒ ïŒ ;
assign ã¹ããŒãã¡ã³ãã¯ããã³ãã¬ãŒãã«form_dataå€æ°ãäœæãã以åã«å®çŸ©ãããé åããããŒã¿ãåã蟌ã¿ãŸãã
æåŸã«ããã³ãã¬ãŒããªããžã§ã¯ãã®è¡šç€ºã¡ãœãããåŒã³åºããŸãããã®ã¡ãœããã¯ããã³ãã¬ãŒããã¡ã€ã«ã解æããããŒã¿è¡šç€ºå Žæããé åããååŸãããããã®å Žæã®å³æããŒã¿ã«çœ®ãæããŸãã 次ã®HTMLã衚瀺ãããŸãã
- //ãã³ãã¬ãŒããã¬ã³ããªã³ã°ããŠè¡šç€ºããŸã
- $ tpl- > display ïŒ 'smarty1.tpl' ïŒ ;
ããŒã¿é å
ãã³ãã¬ãŒããã¡ã€ã«ã«æ £ããåã«ãããžã¥ã¢ã©ã€ã¶ãŒã«ãã£ãŠäœæãããããŒã¿é åã詳ããèŠãŠã¿ãŸãããã ããã¯ããã€ãã®èŠçŽ ã§æ§æããããã®ããã€ãã¯é åã§ããããŸãã ã³ãŒãã¯ããã«é åã®æ§é ã瀺ããŠããŸãã

ããŒã¿ã§æºããããŠãããã®é åã調ã¹ããå Žåã以äžã«ç€ºãããã«ãPHPãã¡ã€ã«ã«è¿œå ã®è¡ãè¿œå ã§ããŸãã

ããŒã¿é åã®åœ¢åŒã«ç²Ÿéããã®ã§ããã³ãã¬ãŒããã¡ã€ã«ã詳现ã«èª¿ã¹ãããšãã§ããŸãã
ã¹ããããã€ã¹ãããïŒãã³ãã¬ãŒããã¡ã€ã«
ãã³ãã¬ãŒããã¡ã€ã«ã¯äž»ã«ãã¬ãŒã³HTMLã§æ§æãããŠããããã®èšäºã®èå³æ·±ãå 容ã¯å«ãŸããŠããŸããã ãã ããSmartyã®ããŸããŸãªã¿ã°ãšã³ãã³ãã¯æ¬åŒ§å ã«ç€ºãããŠããŸãã ããããå匷ããŸãããã
æåã®{literal}ã³ãã³ãã¯ããã¡ã€ã«ã®å é ã«è¡šç€ºãããŸãã

{literal}ã¿ã°ã¯{/ literal}ã¿ã°ã§éããããŠãããããã2ã€ã®ã¿ã°ã®éã«ããããã¹ãã¯åã圢åŒã§è§£éãããã¹ãã§ãããSmartyãã³ãã¬ãŒãã«ãã£ãŠè§£éãããªãããšãæå³ããŸãã ãã®å Žåãããã¹ãã¯ã¹ã¿ã€ã«ã®å®çŸ©ã§ãããããèªäœãæ¬åŒ§ã䜿çšããå¿ èŠãããããããããå¿ èŠã§ãã {literal}ã¿ã°ããªããã°ãSmartyã¯è¡ãtext-alignïŒright;ãšè§£éããŸãã ã¹ããŒããªã¿ã°ã®ããã«ã
次ã®ã³ãã³ã{$ form_data.header.hdrTesting}ã¯ã第2ã¬ãã«ã®ããããŒã®ããã¹ãã圢æããŸãã åã«åŒã³åºããŠããã©ãŒã ããŒã¿ã®é åããã³ãã¬ãŒãã«æž¡ãã次ã®è¡ã§form_dataå€æ°ã«ä¿åããŸããã
- $ tpl- > assign ïŒ 'form_data' ã $ renderer- > toArray ïŒ ïŒ ïŒ ;
ãã®é åã«ã¯ã headerãšããååã®èŠçŽ ããããŸããããã¯ãããŒãããããŒèŠçŽ ã®ååãšããããŒããã¹ããæ¯èŒããããŒã¿ã³ã³ããŒãã³ãã§ããé åã§ããããŸãã è¡{$ form_data.header.hdrTesting}ã¯ã hdrTestingãšããããããŒããã¹ããè¡šã ãããã¯form_dataé åã§ãã³ãã¬ãŒãã«æž¡ãããŸããã
ãã³ãã¬ãŒããã¡ã€ã«å ã®æ®ãã®ã¿ã°ã¯ã form_dataé åã®ç°ãªãèŠçŽ ãåçŽã«ååŸããŸãã èŠåºã以å€ã®åãã©ãŒã èŠçŽ ã«ã¯ã form_dataé åã«ç¬èªã®é åããããŸããããšãã°ã txtFirstNameèŠçŽ ã¯ã次ã®ããã«form_dataé åã§è¡šãããšãã§ããŸãã
- [ "txtFirstName" ] =>
- é å ïŒ 8 ïŒ {
- [ "åå" ] =>
- æååïŒ 12 ïŒ "txtFirstName"
- [ "å€" ] =>
- æååïŒ 5 ïŒ "ããŒã¹"
- [ "ã¿ã€ã" ] =>
- æååïŒ 4 ïŒ "text"
- [ "ããªãŒãº" ] =>
- bool ïŒ true ïŒ
- [ "ã©ãã«" ] =>
- æååïŒ 11 ïŒ "åïŒ"
- [ ãå¿ é ã ] =>
- bool ïŒ false ïŒ
- [ "ãšã©ãŒ" ] =>
- ãã«
- [ "html" ] =>
- æååïŒ 62 ïŒ "ããŒã¹"
- }
ãã®äŸã§ã¯ã form_data.txtFirstName.labelã¯ãFirst nameïŒãã«ãªãã form_data.txtFirstName.htmlã¯ãKeithãã«ãªããŸãã
æåŸã«ããã³ãã¬ãŒãã«ã¯éçæ å ±ãå«ãŸããå ŽåããããŸãã äžèšã®äŸã§ã¯ãèäœæš©æ å ±ã¯éçHTMLã®åœ¢åŒã§ãã³ãã¬ãŒããã¡ã€ã«ã«åã蟌ãŸããŠãããããåžžã«éèªçã«è¡šç€ºãããŸãã
5.ã€ã³ããªãžã§ã³ããªãã³ãã¬ãŒãåŠçã
ã¯ããã«
Smartyãã³ãã¬ãŒãã®äœ¿çšã«é¢ããå®å šãªã¬ã€ãïŒ Smarty Webãµã€ãã§éåžžã«æåããŠããïŒãæžãããšããããšãªãããã®ããŒãã§ã¯ãSmartyãã³ãã¬ãŒãã®ããã€ãã®ç°¡åãªæ©èœãåŠã³ããã³ãã¬ãŒãããã匷åã«ããŸãã
åŠçã¿ã€ããif-then-elseãã
Smartyãã³ãã¬ãŒãã¯ãif-then-elseåŠçããµããŒãããŠããŸãã å ã®ãã³ãã¬ãŒããã¡ã€ã«ã次ã®ããã«å€æŽã§ããŸãã

å€æ°$ form_data.frozenã¯ããŒã«å€ã§ããã©ãŒã ãåçµãããŠããå Žåã¯1ã§ãã ãã©ãŒã ãåããŠè¡šç€ºããããšããã¿ã€ãã«ã¯PHPãã¡ã€ã«ã®ã³ãŒãã«ãã£ãŠæäŸãããhdrTestingå€æ°ã®å€ã«ãªããŸãã ããŒã¿ãéä¿¡ããããšããã©ãŒã ã¯ãåçµããããèµ€ã§è¡šç€ºãããŸãã
ããå®çšçãªäŸã¯ããã©ãŒã ãåºå®ãããŠããªãå Žåã«ãã©ãŒã ã®ãã¿ã³ã衚瀺ããããšã§ãã ããã¯æ¬¡ã®ããã«å®è¡ã§ããŸãã

{if}㯠{/ if}ãéããŸãã Smartyãã³ãã¬ãŒãã¯ã {else}ããã³{elseif}ããŒã¯ãŒãããµããŒãããŠããŸãã ããããã¯æåŸ ã©ããã«æ©èœããŸãã
ããŒã«ã«å€æ°
ãã³ãã¬ãŒãã«ããŒã«ã«å€æ°ãåã蟌ãããšãã§ããŸãã 次ã®äŸã§ã¯ããã©ãŒã ãããªãŒãºãããŠãããã©ããã«åºã¥ããŠã©ãã«ã¹ã¿ã€ã«ãèšå®ããŸãã 䟿å©ãªæ©èœã§ã¯ãããŸããããããŒã«ã«å€æ°ã®äœ¿çšããã瀺ããŠããŸãã ãã³ãã¬ãŒããã¡ã€ã«ã¯ä»¥åãšåãã§ãããããã€ãå€æŽããããŸãã

ãã³ãã¬ãŒãå ã®ã³ã¡ã³ãã
ã³ã¡ã³ãããã³ãã¬ãŒãã«å«ããã«ã¯ãã³ã¡ã³ãã{*ãš*}ã®éã«é 眮ããŸãã äŸïŒ
- {*ããã¯ã³ã¡ã³ãã§ã*}
5.å®çšçãªèæ ®äºé ã
ã¯ããã«
äžèšã®äŸã¯ãè¡ãããããšãæ確ã«ç€ºãããã«ç°¡åãªæ¹æ³ã§ã³ã³ãã€ã«ãããŸããã ãã ããå®éã«ã¯ãããã«è¿œå ããå¿ èŠã®ããè¿œå ã®ãã®ãããã€ããããŸãã ããšãã°ãäžèšã®äŸã§ã¯ãã©ã®ãã£ãŒã«ããå¿ é ãã¯ãŠãŒã¶ãŒã«ããŒã¯ãããŠããŸããã ä»ã«ã泚æãå¿ èŠãªé ç®ããããŸãã
é衚瀺ãã£ãŒã«ããšJavaScript
é衚瀺ãã£ãŒã«ãã¯ãã³ã³ããã¹ãæ å ±ãä¿åããããã«ãã©ãŒã ã§äœ¿çšãããŸãã å€ãã®ãã©ãŒã ã¯JavaScriptã䜿çšããŠããŸããŸãªæ©èœãå®è¡ããŸãã ãåç¥ã®ããã«ãé衚瀺ãã£ãŒã«ããJavaScriptã³ãŒããããŒãžã«è¡šç€ºãããŸãããããã®æ å ±ã¯ãã³ãã¬ãŒããªããžã§ã¯ãã«æž¡ãããé åå ã«ãããŸãã ãã®ããŒã¿ã䜿çšããã«ã¯ã次ã®å€æŽãè¡ãå¿ èŠããããŸãã

å¿ é ãã£ãŒã«ã
ããžã¥ã¢ã©ã€ã¶ãŒã§ã¯ãããã©ã«ãã§ãå¿ é ãã£ãŒã«ãã¯èµ€ãã¢ã¹ã¿ãªã¹ã¯ã§ããŒã¯ããããããã®ãã£ãŒã«ããå¿ é ã§ããããšã瀺ãã¡ã¢ããã©ãŒã ã®äžéšã«é 眮ãããŸãã
ç¬èªã®ãã³ãã¬ãŒããäœæããå Žåããã£ãŒã«ãã«å¿ é ã®ããŒã¯ãä»ããã³ãŒããå«ããå¿ èŠããããŸãïŒãã®ãããªæ©èœãå¿ èŠãªå ŽåïŒã PHPãã¡ã€ã«ã«æ¬¡ã®å€æŽãå ããŠãAgeãã£ãŒã«ããå¿ é ã«ããŸãã
- $ form- > addElement ïŒ 'submit' ã 'btnSubmit' ã 'Submit' ïŒ ;
- $ form- > addRule ïŒ 'txtAge' ã 'Age field required' ã 'required' ïŒ ;
- if ïŒ $ form- > validate ïŒ ïŒ ïŒ {
- ïŒãã©ãŒã ãæ€èšŒãããããããŒã¿ãããªãŒãºããŸã
- $ form- > freeze ïŒ ïŒ ;
- }
ãã®ãã©ãŒã ã衚瀺ãããšã Ageãã£ãŒã«ããå¿ é ã§ããããšã瀺ãããŒã¯ããã©ãŒã ã«ãªãããšãããããŸãã ãŸãã Ageãã£ãŒã«ãã空ã®ãŸãŸã«ãããšããã©ãŒã ã¯ããŒã¿ãéä¿¡ããŸãããããã®çç±ã¯ããããŸããã ãããã®åé¡ãé²ãã«ã¯ã setRequiredTemplateã¡ãœããã䜿çšããŠããžã¥ã¢ã©ã€ã¶ãŒã«ããã€ãã®å€æŽãå ããå¿ èŠããããŸãã ãã³ãã¬ãŒããããã¹ãè¡ã®åŒæ°ãšããŠåãåããŸããããã¡ãããPHPé¢æ°file_get_contentsïŒïŒã䜿çšããŠå€éšãã³ãã¬ãŒããã¡ã€ã«ãèªã¿åãããšãã§ããŸãã ç°¡åã«ããããã«ããã³ãã¬ãŒããçŽæ¥ç€ºããŸãã
Smartyãã³ãã¬ãŒãã¯3ã€ã®å€æ°ãèªèããŸãïŒ
- {$ label}-質åå ã®ã¢ã€ãã ã®ã©ãã«ã
- {$ html}-èŠçŽ ã®HTMLã³ãŒãã
- {$ required}-ãã®èŠçŽ ãå¿ èŠãªå Žåãå€ã¯ãTrueãã«ãªããŸã
次ã®äŸãèªããšãããæ確ã«ãªããŸãã 以äžã«ç€ºãããã«PHPã³ãŒããå€æŽããŸãã

äžèšã®ã³ãŒãããããšã©ãŒãçºçãããšãã¢ã€ãã ã®ã©ãã«ãèµ€ã§è¡šç€ºãããããšãããããŸãã ãšã©ãŒããªãå Žåã¯ãéåžžã©ããã·ã§ãŒãã«ããã衚瀺ããŸãã ãããå¿ é ãã£ãŒã«ãã®å Žåã¯ãå°ããªèµ€ãæãå ¥ããŸãã
ãã©ãŒã ã衚瀺ãããšã Ageãã£ãŒã«ãã«å°ããªèµ€ãã¢ã¹ã¿ãªã¹ã¯ã衚瀺ãããŸãã ãŸãã Ageãã£ãŒã«ãã空çœã®ãŸãŸã«ããŠããŒã¿ãéä¿¡ãããšã Ageãã£ãŒã«ãã«èµ€ãã©ãã«ãä»ãããã©ãŒã ã衚瀺ãããŸãã ãã ãããã©ãŒã ã«ã¯ãèµ€ãã¢ã¹ã¿ãªã¹ã¯ã®æå³ãšã Ageãã£ãŒã«ãã空ã®å Žåã«ããŒã¿ãéä¿¡ãããªãçç±ã瀺ãããŠããŸããã
ãšã©ãŒã¡ãã»ãŒãžã
setRequiredTemplateã¡ãœãããšåæ§ã«ãã¬ã³ãã©ãŒã«ãsetErrorTemplateã¡ãœããããããŸãã setRequiredTemplateã® 3ã€ã®Smartyå€æ°ã«å ããŠã setErrorTemplateã¡ãœããã¯å€æ°ããµããŒãããŸãã addRuleã¡ãœããã®2çªç®ã®åŒæ°ã§å®çŸ©ãããŠããèŠçŽ ã«é¢é£ä»ããããŠãããšã©ãŒããã¹ããå«ãŸããŠããŸãã
次ã«ãPHPã³ãŒãã次ã®ããã«å€æŽããŸãã

ãã®ã³ãŒãã¯ããšã©ãŒãçºçããå Žåããšã©ãŒã¡ãã»ãŒãžãå°ããªãªã¬ã³ãžè²ã®ãã©ã³ãã§è¡šç€ºããå¿ èŠãããããšã瀺ããŠããŸãã ã¢ã€ãã èªäœã¯åžžã«è¡šç€ºãããŸãã å šäœçãªå¹æã¯ããã¹ãŠã®ãã©ãŒã èŠçŽ ã®äžã«ãªã¬ã³ãžè²ã®ãšã©ãŒã¡ãã»ãŒãžã衚瀺ãããããšã§ãã
æåŸã«ãèµ€ãã¢ã¹ã¿ãªã¹ã¯ã®æ£ç¢ºãªæå³ããŠãŒã¶ãŒã«èª¬æããå¿ èŠããããŸãã ãããè¡ãã«ã¯ããã³ãã¬ãŒãã«requirednoteãã£ãŒã«ããè¿œå ããŸãã ãã³ãã¬ãŒããã¡ã€ã«ã次ã®ããã«å€æŽããŸãã

ããã«ãããæšæºããã¹ããrequirednoteãã衚瀺ãããŸãããPHPãã¡ã€ã«èªäœã§å€æŽã§ããŸãã

6.çµè«ã
ãã®ã¬ã€ãã§ã¯ãSmartyã§ã§ããããšãè¡šé¢çã«ã®ã¿ç€ºããŸããã ããããã»ãšãã©ã®å Žåãæãé£ããéšåã¯å§ãŸãã§ãããã®ã¬ã€ãããã®æåã®äžæ©ãèžã¿åºãå©ãã«ãªãããšãé¡ã£ãŠããŸãã 2çªç®ã®äŸ¿å©ãªæé ã¯ãSmartyã®ãã®ä»ã®æ©èœãç解ããããã«Smartyã®ããã¥ã¡ã³ããèªãããšã§ãã