Changeset 1031
- Timestamp:
- 07/20/08 00:45:53 (1 month ago)
- Files:
-
- trunk/lib/jelix/forms/jFormsBase.class.php (modified) (1 diff)
- trunk/lib/jelix/plugins/jforms/html/html.jformsbuilder.php (modified) (2 diffs)
- trunk/lib/jelix/plugins/tpl/html/block.form.php (modified) (4 diffs)
- trunk/lib/jelix/plugins/tpl/html/block.ifctrl.php (modified) (1 diff)
- trunk/lib/jelix/plugins/tpl/html/cfunction.formfull.php (modified) (2 diffs)
- trunk/testapp/modules/jelix_tests/tests/jforms.htmlbuilder.html_cli.php (modified) (5 diffs)
- trunk/testapp/modules/jelix_tests/tests/jtpl.compiler.html_cli.php (modified) (1 diff)
- trunk/testapp/modules/testapp/templates/sampleform.tpl (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/jelix/forms/jFormsBase.class.php
r1030 r1031 553 553 */ 554 554 public function getBuilder($buildertype){ 555 if($buildertype == '') $buildertype = 'html'; 555 556 if(isset($this->builders[$buildertype])){ 556 557 if(isset($this->builders[$buildertype]['inst'])) trunk/lib/jelix/plugins/jforms/html/html.jformsbuilder.php
r1030 r1031 82 82 /** 83 83 * output the header content of the form 84 * @param array $params some parameters 0=>name of the javascript error decorator 85 * 1=> name of the javascript help decorator 86 * 2=> name of method 84 * @param array $params some parameters <ul> 85 * <li>"errDecorator"=>"name of your javascript object for error listener"</li> 86 * <li>"helpDecorator"=>"name of your javascript object for help listener"</li> 87 * <li>"method" => "post" or "get". default is "post"</li> 88 * </ul> 87 89 */ 88 90 public function outputHeader($params){ 91 $params = array_merge(array('errorDecorator'=>'jFormsErrorDecoratorAlert', 92 'helpDecorator'=>'jFormsHelpDecoratorAlert', 'method'=>'post'), $params); 93 89 94 $url = jUrl::get($this->_action, $this->_actionParams, 2); // retourne le jurl correspondant 90 echo '<form action="',$url->scriptName,$url->pathInfo,'" method="'.$params[ 2].'" id="', $this->_name,'"';95 echo '<form action="',$url->scriptName,$url->pathInfo,'" method="'.$params['method'].'" id="', $this->_name,'"'; 91 96 if($this->_form->hasUpload()) 92 97 echo ' enctype="multipart/form-data">'; … … 107 112 echo '<script type="text/javascript"> 108 113 //<![CDATA[ 109 ', $this->getJavascriptCheck($params[ 0],$params[1]),'114 ', $this->getJavascriptCheck($params['errorDecorator'],$params['helpDecorator']),' 110 115 //]]> 111 116 </script>'; trunk/lib/jelix/plugins/tpl/html/block.form.php
r1030 r1031 16 16 * usage : {form $theformobject,'submit_action', $submit_action_params} here form content {/form} 17 17 * 18 * You can add this others parameters : 19 * string $errDecorator name of your javascript object for error listener<br/> 20 * string $helpDecorator name of your javascript object for help listener<br/> 21 * string $method : the method of submit : post or get 18 * You can add this others parameters :<ul> 19 * <li>string $builderName (default is 'html')</li> 20 * <li>array $options for the builder. Example, for the 'html' builder : <ul> 21 * <li>"errDecorator"=>"name of your javascript object for error listener"</li> 22 * <li>"helpDecorator"=>"name of your javascript object for help listener"</li> 23 * <li>"method" => "post" or "get". default is "post"</li> 24 * </ul> 25 * </li> 26 * </ul> 22 27 * 23 28 * @param jTplCompiler $compiler the template compiler … … 26 31 * 1=>selector of submit action 27 32 * 2=>array of parameters for submit action 28 * 3=>name of your javascript object for error listener 29 * 4=>name of your javascript object for help listener 30 * 5=>name of the method : 'post' or 'get' 31 * 6=>name of the builder : default is html 33 * 3=>name of the builder : default is html 34 * 4=>array of options for the builder 32 35 * @return string the php code corresponding to the begin or end of the block 33 36 * @see jForms … … 43 46 } 44 47 45 if(count($param) < 2 || count($param) > 7){46 $compiler->doError2('errors.tplplugin.block.bad.argument.number','form','2- 7');48 if(count($param) < 2 || count($param) > 5){ 49 $compiler->doError2('errors.tplplugin.block.bad.argument.number','form','2-5'); 47 50 return ''; 48 51 } … … 52 55 53 56 if(isset($param[3]) && $param[3] != '""' && $param[3] != "''") 54 $errdecorator = $param[3]; 55 else 56 $errdecorator = "'jFormsErrorDecoratorAlert'"; 57 58 if(isset($param[4]) && $param[4] != '""' && $param[4] != "''") 59 $helpdecorator = $param[4]; 60 else 61 $helpdecorator = "'jFormsHelpDecoratorAlert'"; 62 63 $method = isset($param[5])?$param[5]:'\'post\''; 64 65 if(isset($param[6]) && $param[6] != '""' && $param[6] != "''") 66 $builder = $param[6]; 57 $builder = $param[3]; 67 58 else 68 59 $builder = "'html'"; 60 61 if(isset($param[4])) 62 $options = $param[4]; 63 else 64 $options = "array()"; 69 65 70 66 $content = ' $t->_privateVars[\'__form\'] = '.$param[0].'; 71 67 $t->_privateVars[\'__formbuilder\'] = $t->_privateVars[\'__form\']->getBuilder('.$builder.'); 72 68 $t->_privateVars[\'__formbuilder\']->setAction('.$param[1].','.$param[2].'); 73 $t->_privateVars[\'__formbuilder\']->outputHeader( array('.$errdecorator.','.$helpdecorator.','.$method.'));69 $t->_privateVars[\'__formbuilder\']->outputHeader('.$options.'); 74 70 $t->_privateVars[\'__displayed_ctrl\'] = array(); 75 71 '; trunk/lib/jelix/plugins/tpl/html/block.ifctrl.php
r1026 r1031 13 13 * TO BE USED inside a {formcontrols} block 14 14 * 15 * {ifctrl 'name1','name2',...} some tpl{else}some other tpl{/ifctrl}15 * {ifctrl 'name1','name2',...} some tpl {else} some other tpl {/ifctrl} 16 16 * @param jTplCompiler $compiler the template compiler 17 17 * @param boolean $begin true if it is the begin of block, else false trunk/lib/jelix/plugins/tpl/html/cfunction.formfull.php
r955 r1031 14 14 * Display a full form without the use of other plugins. 15 15 * usage : {formfull $theformobject,'submit_action', $submit_action_params} 16 * You can add this others parameters : 17 * string $errDecorator name of your javascript object for error listener<br/> 18 * string $helpDecorator name of your javascript object for help listener<br/> 19 * string $method : the method of submit : 'post' or 'get' 20 * 16 * 17 * You can add this others parameters :<ul> 18 * <li>string $builderName (default is 'html')</li> 19 * <li>array $options for the builder. Example, for the 'html' builder : <ul> 20 * <li>"errDecorator"=>"name of your javascript object for error listener"</li> 21 * <li>"helpDecorator"=>"name of your javascript object for help listener"</li> 22 * <li>"method" => "post" or "get". default is "post"</li> 23 * </ul> 24 * </li> 25 * </ul> 21 26 * @param jTplCompiler $compiler the template compiler 22 * @param array $params 0=>form object 23 * 1=>selector of submit action 24 * 2=>array of parameters for submit action 25 * 3=>name of your javascript object for error listener 26 * 4=>name of your javascript object for help listener 27 * 5=>name of the method : POST or GET 28 * 6=>name of the builder : default is html 27 * @param array $param 0=>form object 28 * 1=>selector of submit action 29 * 2=>array of parameters for submit action 30 * 3=>name of the builder : default is html 31 * 4=>array of options for the builder 29 32 * @return string the php code corresponding to the begin or end of the block 30 33 */ 31 34 function jtpl_cfunction_html_formfull($compiler, $params=array()) 32 35 { 33 if (count($params) < 2 || count($params) > 7) {34 $compiler->doError2('errors.tplplugin.cfunction.bad.argument.number','formfull','2- 7');36 if (count($params) < 2 || count($params) > 5) { 37 $compiler->doError2('errors.tplplugin.cfunction.bad.argument.number','formfull','2-5'); 35 38 } 36 39 37 if(isset($param s[6]) && $params[6] != '""' && $params[6] != "''")38 $builder = $param s[6];39 else 40 if(isset($param[3]) && $param[3] != '""' && $param[3] != "''") 41 $builder = $param[3]; 42 else 40 43 $builder = "'html'"; 41 44 … … 45 48 $params[2] = 'array()'; 46 49 } 47 if(isset($params[3]) && $params[3] != '""' && $params[3] != "''") 48 $errdecorator = $params[3]; 50 51 if(isset($param[4])) 52 $options = $param[4]; 49 53 else 50 $errdecorator = "'jFormsErrorDecoratorAlert'"; 51 52 if(isset($params[4]) && $params[4] != '""' && $params[4] != "''") 53 $helpdecorator = $params[4]; 54 else 55 $helpdecorator = "'jFormsHelpDecoratorAlert'"; 56 57 $method = isset($params[5])?$params[5]:'\'post\''; 54 $options = "array()"; 58 55 59 56 $content = ' $formfull = '.$params[0].'; 60 57 $formfullBuilder = $formfull->getBuilder('.$builder.'); 61 58 $formfullBuilder->setAction('.$params[1].','.$params[2].'); 62 $formfullBuilder->outputHeader( array('.$errdecorator.','.$helpdecorator.','.$method.'));59 $formfullBuilder->outputHeader('.$options.')); 63 60 $formfullBuilder->outputAllControls(); 64 61 $formfullBuilder->outputFooter();'; trunk/testapp/modules/jelix_tests/tests/jforms.htmlbuilder.html_cli.php
r1030 r1031 42 42 $this->builder->setAction('jelix_tests~urlsig:url1',array()); 43 43 ob_start(); 44 $this->builder->outputHeader(array(' ','','post'));44 $this->builder->outputHeader(array('method'=>'post')); 45 45 $out = ob_get_clean(); 46 46 $result ='<form action="'.$GLOBALS['gJConfig']->urlengine['basePath'].'index.php" method="post" id="'.$this->builder->getName().'"><div class="jforms-hiddens"><input type="hidden" name="module" value="jelix_tests"/> … … 55 55 $this->builder->setAction('jelix_tests~urlsig:url1',array('foo'=>'b>ar')); 56 56 ob_start(); 57 $this->builder->outputHeader(array(' ','','get'));57 $this->builder->outputHeader(array('method'=>'get')); 58 58 $out = ob_get_clean(); 59 59 $result ='<form action="'.$GLOBALS['gJConfig']->urlengine['basePath'].'index.php" method="get" id="'.$this->builder->getName().'"><div class="jforms-hiddens"><input type="hidden" name="foo" value="b>ar"/> … … 791 791 792 792 ob_start(); 793 $this->builder->outputHeader(array(' ','','post'));793 $this->builder->outputHeader(array('method'=>'post')); 794 794 $out = ob_get_clean(); 795 795 $result ='<form action="'.$GLOBALS['gJConfig']->urlengine['basePath'].'index.php" method="post" id="'.$this->formname.'" enctype="multipart/form-data"><div class="jforms-hiddens"><input type="hidden" name="foo" value="b>ar"/> … … 867 867 868 868 ob_start(); 869 $this->builder->outputHeader(array(' ','','post'));869 $this->builder->outputHeader(array('method'=>'post')); 870 870 $out = ob_get_clean(); 871 871 $result ='<form action="'.$GLOBALS['gJConfig']->urlengine['basePath'].'index.php" method="post" id="'.$this->formname.'"><div class="jforms-hiddens"><input type="hidden" name="foo" value="b>ar"/> … … 885 885 $this->form->addControl($ctrl); 886 886 ob_start(); 887 $this->builder->outputHeader(array(' ','','post'));887 $this->builder->outputHeader(array('method'=>'post')); 888 888 $out = ob_get_clean(); 889 889 $result ='<form action="'.$GLOBALS['gJConfig']->urlengine['basePath'].'index.php" method="post" id="'.$this->formname.'"><div class="jforms-hiddens"><input type="hidden" name="foo" value="b>ar"/> trunk/testapp/modules/jelix_tests/tests/jtpl.compiler.html_cli.php
r998 r1031 210 210 'jelix~errors.tpl.tag.character.invalid',array('for ($i=0;$i<$p;$i++)','(',null) ), 211 211 4=>array('{form ($foo,$params)} aa {/form}', 212 'jelix~errors.tplplugin.block.bad.argument.number',array('form','2- 7',null) ),212 'jelix~errors.tplplugin.block.bad.argument.number',array('form','2-5',null) ), 213 213 5=>array('{($aaa)}', 214 214 'jelix~errors.tpl.tag.syntax.invalid',array('($aaa)',null) ), trunk/testapp/modules/testapp/templates/sampleform.tpl
r1030 r1031 27 27 </script> 28 28 29 {form $form,'sampleform:save', array(), ' myErrorDecorator'}29 {form $form,'sampleform:save', array(), 'html', array('errorDecorator'=>'myErrorDecorator')} 30 30 {formcontrols} 31 31 <div>{ctrl_label}: {ctrl_control}</div>
