Changeset 452
- Timestamp:
- 06/02/07 00:31:58 (2 years ago)
- Files:
-
- branches/experimental/jforms/build/manifests/jelix-lib.mn (modified) (1 diff)
- branches/experimental/jforms/build/manifests/jelix-lib.mn (modified) (1 diff)
- branches/experimental/jforms/lib/jelix-modules/jelix/locales/en_EN/formserr.ISO-8859-1.properties (modified) (1 diff)
- branches/experimental/jforms/lib/jelix-modules/jelix/locales/en_EN/formserr.ISO-8859-1.properties (modified) (1 diff)
- branches/experimental/jforms/lib/jelix-modules/jelix/locales/en_EN/formserr.UTF-8.properties (modified) (1 diff)
- branches/experimental/jforms/lib/jelix-modules/jelix/locales/en_EN/formserr.UTF-8.properties (modified) (1 diff)
- branches/experimental/jforms/lib/jelix-modules/jelix/locales/en_US/formserr.ISO-8859-1.properties (modified) (1 diff)
- branches/experimental/jforms/lib/jelix-modules/jelix/locales/en_US/formserr.ISO-8859-1.properties (modified) (1 diff)
- branches/experimental/jforms/lib/jelix-modules/jelix/locales/en_US/formserr.UTF-8.properties (modified) (1 diff)
- branches/experimental/jforms/lib/jelix-modules/jelix/locales/en_US/formserr.UTF-8.properties (modified) (1 diff)
- branches/experimental/jforms/lib/jelix-modules/jelix/locales/fr_FR/formserr.ISO-8859-1.properties (modified) (1 diff)
- branches/experimental/jforms/lib/jelix-modules/jelix/locales/fr_FR/formserr.ISO-8859-1.properties (modified) (1 diff)
- branches/experimental/jforms/lib/jelix-modules/jelix/locales/fr_FR/formserr.UTF-8.properties (modified) (1 diff)
- branches/experimental/jforms/lib/jelix-modules/jelix/locales/fr_FR/formserr.UTF-8.properties (modified) (1 diff)
- branches/experimental/jforms/lib/jelix-www/js/jforms.js (modified) (1 diff)
- branches/experimental/jforms/lib/jelix-www/js/jforms.js (modified) (1 diff)
- branches/experimental/jforms/lib/jelix/forms/jFormsBuilderBase.class.php (modified) (5 diffs)
- branches/experimental/jforms/lib/jelix/forms/jFormsBuilderBase.class.php (modified) (5 diffs)
- branches/experimental/jforms/lib/jelix/forms/jFormsCompiler.class.php (modified) (4 diffs)
- branches/experimental/jforms/lib/jelix/forms/jFormsCompiler.class.php (modified) (4 diffs)
- branches/experimental/jforms/lib/jelix/tpl/plugins/html/block.form.php (modified) (3 diffs)
- branches/experimental/jforms/lib/jelix/tpl/plugins/html/block.form.php (modified) (3 diffs)
- branches/experimental/jforms/lib/jelix/tpl/plugins/html/block.formcontrols.php (modified) (1 diff)
- branches/experimental/jforms/lib/jelix/tpl/plugins/html/block.formcontrols.php (modified) (1 diff)
- branches/experimental/jforms/testapp/modules/testapp/forms/sample.form.xml (modified) (1 diff)
- branches/experimental/jforms/testapp/modules/testapp/forms/sample.form.xml (modified) (1 diff)
- branches/experimental/jforms/testapp/modules/testapp/templates/sampleform.tpl (modified) (1 diff)
- branches/experimental/jforms/testapp/modules/testapp/templates/sampleform.tpl (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/experimental/jforms/build/manifests/jelix-lib.mn
r442 r452 341 341 cd lib/jelix-www/js 342 342 tooltip.js 343 jforms.js 343 344 cd lib/jelix-www/xul 344 345 jxulform.css branches/experimental/jforms/build/manifests/jelix-lib.mn
r442 r452 341 341 cd lib/jelix-www/js 342 342 tooltip.js 343 jforms.js 343 344 cd lib/jelix-www/xul 344 345 jxulform.css branches/experimental/jforms/lib/jelix-modules/jelix/locales/en_EN/formserr.ISO-8859-1.properties
r441 r452 6 6 invalid.xml.file=(805) invalid xml syntax in jforms file (file %s) 7 7 8 js.err.invalid= "%s" field is invalid 9 js.err.required= "%s" field is required branches/experimental/jforms/lib/jelix-modules/jelix/locales/en_EN/formserr.ISO-8859-1.properties
r441 r452 6 6 invalid.xml.file=(805) invalid xml syntax in jforms file (file %s) 7 7 8 js.err.invalid= "%s" field is invalid 9 js.err.required= "%s" field is required branches/experimental/jforms/lib/jelix-modules/jelix/locales/en_EN/formserr.UTF-8.properties
r441 r452 6 6 invalid.xml.file=(805) invalid xml syntax in jforms file (file %s) 7 7 8 js.err.invalid= "%s" field is invalid 9 js.err.required= "%s" field is required branches/experimental/jforms/lib/jelix-modules/jelix/locales/en_EN/formserr.UTF-8.properties
r441 r452 6 6 invalid.xml.file=(805) invalid xml syntax in jforms file (file %s) 7 7 8 js.err.invalid= "%s" field is invalid 9 js.err.required= "%s" field is required branches/experimental/jforms/lib/jelix-modules/jelix/locales/en_US/formserr.ISO-8859-1.properties
r441 r452 5 5 datatype.unknow=(804) unknow datatype %1$s on %2$s (file %3$s) 6 6 invalid.xml.file=(805) invalid xml syntax in jforms file (file %s) 7 8 js.err.invalid= "%s" field is invalid 9 js.err.required= "%s" field is required 10 branches/experimental/jforms/lib/jelix-modules/jelix/locales/en_US/formserr.ISO-8859-1.properties
r441 r452 5 5 datatype.unknow=(804) unknow datatype %1$s on %2$s (file %3$s) 6 6 invalid.xml.file=(805) invalid xml syntax in jforms file (file %s) 7 8 js.err.invalid= "%s" field is invalid 9 js.err.required= "%s" field is required 10 branches/experimental/jforms/lib/jelix-modules/jelix/locales/en_US/formserr.UTF-8.properties
r441 r452 5 5 datatype.unknow=(804) unknow datatype %1$s on %2$s (file %3$s) 6 6 invalid.xml.file=(805) invalid xml syntax in jforms file (file %s) 7 8 js.err.invalid= "%s" field is invalid 9 js.err.required= "%s" field is required branches/experimental/jforms/lib/jelix-modules/jelix/locales/en_US/formserr.UTF-8.properties
r441 r452 5 5 datatype.unknow=(804) unknow datatype %1$s on %2$s (file %3$s) 6 6 invalid.xml.file=(805) invalid xml syntax in jforms file (file %s) 7 8 js.err.invalid= "%s" field is invalid 9 js.err.required= "%s" field is required branches/experimental/jforms/lib/jelix-modules/jelix/locales/fr_FR/formserr.ISO-8859-1.properties
r441 r452 6 6 invalid.xml.file=(805) erreur de syntaxe xml dans un fichier jforms (fichier %s) 7 7 8 js.err.invalid=La saisie de "%s" est invalide 9 js.err.required=La saisie de "%s" est obligatoire branches/experimental/jforms/lib/jelix-modules/jelix/locales/fr_FR/formserr.ISO-8859-1.properties
r441 r452 6 6 invalid.xml.file=(805) erreur de syntaxe xml dans un fichier jforms (fichier %s) 7 7 8 js.err.invalid=La saisie de "%s" est invalide 9 js.err.required=La saisie de "%s" est obligatoire branches/experimental/jforms/lib/jelix-modules/jelix/locales/fr_FR/formserr.UTF-8.properties
r441 r452 5 5 datatype.unknow=(804) datatype inconnu %1$s sur %2$s (fichier %3$s) 6 6 invalid.xml.file=(805) erreur de syntaxe xml dans un fichier jforms (fichier %s) 7 8 js.err.invalid=La saisie de "%s" est invalide 9 js.err.required=La saisie de "%s" est obligatoire branches/experimental/jforms/lib/jelix-modules/jelix/locales/fr_FR/formserr.UTF-8.properties
r441 r452 5 5 datatype.unknow=(804) datatype inconnu %1$s sur %2$s (fichier %3$s) 6 6 invalid.xml.file=(805) erreur de syntaxe xml dans un fichier jforms (fichier %s) 7 8 js.err.invalid=La saisie de "%s" est invalide 9 js.err.required=La saisie de "%s" est obligatoire branches/experimental/jforms/lib/jelix-www/js/jforms.js
r437 r452 166 166 _getValue : function (elt){ 167 167 var value=''; 168 switch (elt.localName ) {168 switch (elt.localName.toLowerCase()) { 169 169 case "input": 170 switch (elt.type) { 171 case "text": 172 case "password": 173 case "hidden": 174 value = elt.value; 175 break; 176 case "checkbox": 177 case "radio": 178 if (elt.checked) 179 value = 'true'; 180 else 181 value = 'false'; 182 break; 170 switch (elt.getAttribute("type")) { 171 case "checkbox": 172 case "radio": 173 if (elt.checked) 174 value = 'true'; 175 else 176 value = 'false'; 177 break; 178 default: 179 value = elt.value; 180 break; 183 181 } 184 182 break; 185 186 183 case "textarea": 187 184 value= elt.value; branches/experimental/jforms/lib/jelix-www/js/jforms.js
r437 r452 166 166 _getValue : function (elt){ 167 167 var value=''; 168 switch (elt.localName ) {168 switch (elt.localName.toLowerCase()) { 169 169 case "input": 170 switch (elt.type) { 171 case "text": 172 case "password": 173 case "hidden": 174 value = elt.value; 175 break; 176 case "checkbox": 177 case "radio": 178 if (elt.checked) 179 value = 'true'; 180 else 181 value = 'false'; 182 break; 170 switch (elt.getAttribute("type")) { 171 case "checkbox": 172 case "radio": 173 if (elt.checked) 174 value = 'true'; 175 else 176 value = 'false'; 177 break; 178 default: 179 value = elt.value; 180 break; 183 181 } 184 182 break; 185 186 183 case "textarea": 187 184 value= elt.value; branches/experimental/jforms/lib/jelix/forms/jFormsBuilderBase.class.php
r442 r452 57 57 public function getName(){ return $this->_name; } 58 58 59 abstract public function outputHeader( );59 abstract public function outputHeader($params); 60 60 61 61 abstract public function outputFooter(); … … 73 73 abstract class jFormsHtmlBuilderBase extends jFormsBuilderBase { 74 74 75 public function outputHeader( ){75 public function outputHeader($params){ 76 76 $url = jUrl::get($this->_action, $this->_actionParams, 2); // retourne le jurl correspondant 77 78 echo '<form action="'.$url->scriptName . $url->pathInfo.'" method="POST" name="'. $this->_name.'">'; 77 echo '<form action="'.$url->scriptName . $url->pathInfo.'" method="POST" name="'. $this->_name.'" onsubmit="return jForms.verifyForm(this)">'; 79 78 if(count($url->params)){ 80 79 echo '<div>'; … … 84 83 echo '</div>'; 85 84 } 85 echo '<script type="text/javascript"> 86 //<[CDATA[ 87 ', $this->getJavascriptCheck($params),' 88 //]]> 89 </script>'; 86 90 87 91 } … … 102 106 103 107 public function outputControl($ctrl){ 104 $id = 'name="'.$ctrl->ref.'" id="' $this->_name.'_'.$ctrl->ref.'"';108 $id = 'name="'.$ctrl->ref.'" id="'.$this->_name.'_'.$ctrl->ref.'"'; 105 109 $readonly = ($ctrl->readonly?' readonly="readonly"':''); 106 110 switch($ctrl->type){ … … 132 136 133 137 134 abstract public function getJavascriptCheck( );138 abstract public function getJavascriptCheck($params); 135 139 } 136 140 branches/experimental/jforms/lib/jelix/forms/jFormsBuilderBase.class.php
r442 r452 57 57 public function getName(){ return $this->_name; } 58 58 59 abstract public function outputHeader( );59 abstract public function outputHeader($params); 60 60 61 61 abstract public function outputFooter(); … … 73 73 abstract class jFormsHtmlBuilderBase extends jFormsBuilderBase { 74 74 75 public function outputHeader( ){75 public function outputHeader($params){ 76 76 $url = jUrl::get($this->_action, $this->_actionParams, 2); // retourne le jurl correspondant 77 78 echo '<form action="'.$url->scriptName . $url->pathInfo.'" method="POST" name="'. $this->_name.'">'; 77 echo '<form action="'.$url->scriptName . $url->pathInfo.'" method="POST" name="'. $this->_name.'" onsubmit="return jForms.verifyForm(this)">'; 79 78 if(count($url->params)){ 80 79 echo '<div>'; … … 84 83 echo '</div>'; 85 84 } 85 echo '<script type="text/javascript"> 86 //<[CDATA[ 87 ', $this->getJavascriptCheck($params),' 88 //]]> 89 </script>'; 86 90 87 91 } … … 102 106 103 107 public function outputControl($ctrl){ 104 $id = 'name="'.$ctrl->ref.'" id="' $this->_name.'_'.$ctrl->ref.'"';108 $id = 'name="'.$ctrl->ref.'" id="'.$this->_name.'_'.$ctrl->ref.'"'; 105 109 $readonly = ($ctrl->readonly?' readonly="readonly"':''); 106 110 switch($ctrl->type){ … … 132 136 133 137 134 abstract public function getJavascriptCheck( );138 abstract public function getJavascriptCheck($params); 135 139 } 136 140 branches/experimental/jforms/lib/jelix/forms/jFormsCompiler.class.php
r442 r452 63 63 $srcjs=array(); 64 64 $srcjs[]='$js="gForm = new jFormsForm(\'".$this->_name."\');\n";'; 65 $srcjs[]='$js.="gForm.setDecorator(new jFormsErrorDecoratorAlert());\n";';65 $srcjs[]='$js.="gForm.setDecorator(new ".$errorDecoratorName."());\n";'; 66 66 foreach($xml->children() as $controltype=>$control){ 67 67 $source[] = $this->generatePHPControl($controltype, $control); … … 77 77 $srcjs[]='$js.="jForms.declareForm(gForm);\n";'; 78 78 79 $srcHtmlBuilder[]=' public function getJavascriptCheck( ){';79 $srcHtmlBuilder[]=' public function getJavascriptCheck($errorDecoratorName){'; 80 80 $srcHtmlBuilder[]= implode("\n", $srcjs); 81 $srcHtmlBuilder[]=' return $ verif; }';81 $srcHtmlBuilder[]=' return $js; }'; 82 82 $srcHtmlBuilder[]='} ?>'; 83 83 … … 184 184 185 185 if(isset($control->label['locale'])){ 186 $ label='\'".str_replace("\'","\\\'",jLocale::get(\''.(string)$control->label['locale'].'\'))."\'';186 $source[]='$label = str_replace("\'","\\\'",jLocale::get(\''.(string)$control->label['locale'].'\'));'; 187 187 }else{ 188 $label="'".str_replace("'","\\'",(string)$control->label)."'"; 189 $label=str_replace('"','\"',$label); 188 $source[]='$label = str_replace("\'","\\\'",\''.str_replace("'","\\'",(string)$control->label).'\');'; 190 189 } 191 $source[]='$js.="gControl = new jFormsControl(\''.(string)$control['ref'].'\', '.$label.', \''.$dt.'\');\n";'; 192 190 $source[]='$js.="gControl = new jFormsControl(\''.(string)$control['ref'].'\', \'".$label."\', \''.$dt.'\');\n";'; 193 191 194 192 if(isset($control['readonly'])){ … … 200 198 $source[]='$js.="gControl.required = '.($required=='true'?'true':'false').';\n";'; 201 199 } 200 201 $source[]='$js.="gControl.errRequired=\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.required\',$label))."\';\n";'; 202 $source[]='$js.="gControl.errInvalid =\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.invalid\', $label))."\';\n";'; 202 203 203 204 /* branches/experimental/jforms/lib/jelix/forms/jFormsCompiler.class.php
r442 r452 63 63 $srcjs=array(); 64 64 $srcjs[]='$js="gForm = new jFormsForm(\'".$this->_name."\');\n";'; 65 $srcjs[]='$js.="gForm.setDecorator(new jFormsErrorDecoratorAlert());\n";';65 $srcjs[]='$js.="gForm.setDecorator(new ".$errorDecoratorName."());\n";'; 66 66 foreach($xml->children() as $controltype=>$control){ 67 67 $source[] = $this->generatePHPControl($controltype, $control); … … 77 77 $srcjs[]='$js.="jForms.declareForm(gForm);\n";'; 78 78 79 $srcHtmlBuilder[]=' public function getJavascriptCheck( ){';79 $srcHtmlBuilder[]=' public function getJavascriptCheck($errorDecoratorName){'; 80 80 $srcHtmlBuilder[]= implode("\n", $srcjs); 81 $srcHtmlBuilder[]=' return $ verif; }';81 $srcHtmlBuilder[]=' return $js; }'; 82 82 $srcHtmlBuilder[]='} ?>'; 83 83 … … 184 184 185 185 if(isset($control->label['locale'])){ 186 $ label='\'".str_replace("\'","\\\'",jLocale::get(\''.(string)$control->label['locale'].'\'))."\'';186 $source[]='$label = str_replace("\'","\\\'",jLocale::get(\''.(string)$control->label['locale'].'\'));'; 187 187 }else{ 188 $label="'".str_replace("'","\\'",(string)$control->label)."'"; 189 $label=str_replace('"','\"',$label); 188 $source[]='$label = str_replace("\'","\\\'",\''.str_replace("'","\\'",(string)$control->label).'\');'; 190 189 } 191 $source[]='$js.="gControl = new jFormsControl(\''.(string)$control['ref'].'\', '.$label.', \''.$dt.'\');\n";'; 192 190 $source[]='$js.="gControl = new jFormsControl(\''.(string)$control['ref'].'\', \'".$label."\', \''.$dt.'\');\n";'; 193 191 194 192 if(isset($control['readonly'])){ … … 200 198 $source[]='$js.="gControl.required = '.($required=='true'?'true':'false').';\n";'; 201 199 } 200 201 $source[]='$js.="gControl.errRequired=\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.required\',$label))."\';\n";'; 202 $source[]='$js.="gControl.errInvalid =\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.invalid\', $label))."\';\n";'; 202 203 203 204 /* branches/experimental/jforms/lib/jelix/tpl/plugins/html/block.form.php
r442 r452 13 13 * 14 14 * usage : {form $theformobject,'submit_action', $submit_action_params} here form content {/form} 15 * 15 * 16 16 * @param jTplCompiler $compiler the template compiler 17 * @param boolean true if it is the begin of block, else false 18 * @param $param array 0=>form object 1=>selector of submit action 2=>array of parameters for submit action 17 * @param boolean $begin true if it is the begin of block, else false 18 * @param array $param 0=>form object 19 * 1=>selector of submit action 20 * 2=>array of parameters for submit action 21 * 3=>name of your javascript object for error listener 19 22 * @return string the php code corresponding to the begin or end of the block 20 23 * @see jForms … … 29 32 } 30 33 31 if(count($param) < 2 || count($param) > 3){34 if(count($param) < 2 || count($param) > 4){ 32 35 $compiler->doError2('errors.tplplugin.block.bad.argument.number','form',2); 33 36 return ''; … … 37 40 } 38 41 42 if(isset($param[3])) 43 $errdecorator = $param[3]; 44 else 45 $errdecorator = "'jFormsErrorDecoratorAlert'"; 46 39 47 $content = ' $t->_privateVars[\'__form\'] = '.$param[0].'; 40 48 $t->_privateVars[\'__builder\'] = $t->_privateVars[\'__form\']->getBuilder(\'html\', '.$param[1].','.$param[2].'); 41 $t->_privateVars[\'__builder\']->outputHeader(); 49 $t->_privateVars[\'__builder\']->outputHeader('.$errdecorator.'); 50 if($GLOBALS[\'gJCoord\']->response!= null){ 51 $GLOBALS[\'gJCoord\']->response->addJSLink($GLOBALS[\'gJConfig\']->urlengine[\'basePath\'].\'jelix/js/jforms.js\'); 52 } 42 53 '; 43 44 $rep = $GLOBALS['gJCoord']->response;45 if($rep!= null){46 $rep->addJSLink($GLOBALS['gJConfig']->urlengine['basePath'].'jelix/js/jforms.js');47 }48 54 49 55 return $content; branches/experimental/jforms/lib/jelix/tpl/plugins/html/block.form.php
r442 r452 13 13 * 14 14 * usage : {form $theformobject,'submit_action', $submit_action_params} here form content {/form} 15 * 15 * 16 16 * @param jTplCompiler $compiler the template compiler 17 * @param boolean true if it is the begin of block, else false 18 * @param $param array 0=>form object 1=>selector of submit action 2=>array of parameters for submit action 17 * @param boolean $begin true if it is the begin of block, else false 18 * @param array $param 0=>form object 19 * 1=>selector of submit action 20 * 2=>array of parameters for submit action 21 * 3=>name of your javascript object for error listener 19 22 * @return string the php code corresponding to the begin or end of the block 20 23 * @see jForms … … 29 32 } 30 33 31 if(count($param) < 2 || count($param) > 3){34 if(count($param) < 2 || count($param) > 4){ 32 35 $compiler->doError2('errors.tplplugin.block.bad.argument.number','form',2); 33 36 return ''; … … 37 40 } 38 41 42 if(isset($param[3])) 43 $errdecorator = $param[3]; 44 else 45 $errdecorator = "'jFormsErrorDecoratorAlert'"; 46 39 47 $content = ' $t->_privateVars[\'__form\'] = '.$param[0].'; 40 48 $t->_privateVars[\'__builder\'] = $t->_privateVars[\'__form\']->getBuilder(\'html\', '.$param[1].','.$param[2].'); 41 $t->_privateVars[\'__builder\']->outputHeader(); 49 $t->_privateVars[\'__builder\']->outputHeader('.$errdecorator.'); 50 if($GLOBALS[\'gJCoord\']->response!= null){ 51 $GLOBALS[\'gJCoord\']->response->addJSLink($GLOBALS[\'gJConfig\']->urlengine[\'basePath\'].\'jelix/js/jforms.js\'); 52 } 42 53 '; 43 44 $rep = $GLOBALS['gJCoord']->response;45 if($rep!= null){46 $rep->addJSLink($GLOBALS['gJConfig']->urlengine['basePath'].'jelix/js/jforms.js');47 }48 54 49 55 return $content; branches/experimental/jforms/lib/jelix/tpl/plugins/html/block.formcontrols.php
r442 r452 15 15 * 16 16 * @param jTplCompiler $compiler the template compiler 17 * @param boolean true if it is the begin of block, else false18 * @param $param array empty or a jFormBase object as first item17 * @param boolean $begin true if it is the begin of block, else false 18 * @param array $param array empty or a jFormBase object as first item 19 19 * @return string the php code corresponding to the begin or end of the block 20 20 * @see jForms branches/experimental/jforms/lib/jelix/tpl/plugins/html/block.formcontrols.php
r442 r452 15 15 * 16 16 * @param jTplCompiler $compiler the template compiler 17 * @param boolean true if it is the begin of block, else false18 * @param $param array empty or a jFormBase object as first item17 * @param boolean $begin true if it is the begin of block, else false 18 * @param array $param array empty or a jFormBase object as first item 19 19 * @return string the php code corresponding to the begin or end of the block 20 20 * @see jForms branches/experimental/jforms/testapp/modules/testapp/forms/sample.form.xml
r442 r452 2 2 <forms xmlns="http://jelix.org/ns/forms/1.0"> 3 3 4 <input ref="nom" >4 <input ref="nom" required="true"> 5 5 <label>Votre nom</label> 6 6 </input> branches/experimental/jforms/testapp/modules/testapp/forms/sample.form.xml
r442 r452 2 2 <forms xmlns="http://jelix.org/ns/forms/1.0"> 3 3 4 <input ref="nom" >4 <input ref="nom" required="true"> 5 5 <label>Votre nom</label> 6 6 </input> branches/experimental/jforms/testapp/modules/testapp/templates/sampleform.tpl
r442 r452 1 1 <h1>Test de formulaire</h1> 2 2 <p>Voici un formulaire de test</p> 3 {form $form,'sampleform_save'} 3 <script type="text/javascript"> 4 {literal} 5 function myErrorDecorator(){ 6 this.message = ''; 7 } 8 9 myErrorDecorator.prototype = { 10 start : function(){ 11 this.message = ''; 12 }, 13 addError : function(control, messageType){ 14 if(messageType == 1){ 15 this.message += control.errRequired + "\n"; 16 }else if(messageType == 2){ 17 this.message += control.errInvalid + "\n"; 18 } 19 }, 20 end : function(){ 21 if(this.message != ''){ 22 alert("Erreur de saisie:\n" + this.message); 23 } 24 } 25 } 26 {/literal} 27 </script> 28 29 {form $form,'sampleform_save', array(), 'myErrorDecorator'} 4 30 <fieldset> 5 31 <legend>Votre identité</legend> branches/experimental/jforms/testapp/modules/testapp/templates/sampleform.tpl
r442 r452 1 1 <h1>Test de formulaire</h1> 2 2 <p>Voici un formulaire de test</p> 3 {form $form,'sampleform_save'} 3 <script type="text/javascript"> 4 {literal} 5 function myErrorDecorator(){ 6 this.message = ''; 7 } 8 9 myErrorDecorator.prototype = { 10 start : function(){ 11 this.message = ''; 12 }, 13 addError : function(control, messageType){ 14 if(messageType == 1){ 15 this.message += control.errRequired + "\n"; 16 }else if(messageType == 2){ 17 this.message += control.errInvalid + "\n"; 18 } 19 }, 20 end : function(){ 21 if(this.message != ''){ 22 alert("Erreur de saisie:\n" + this.message); 23 } 24 } 25 } 26 {/literal} 27 </script> 28 29 {form $form,'sampleform_save', array(), 'myErrorDecorator'} 4 30 <fieldset> 5 31 <legend>Votre identité</legend>
