Changeset 650
- Timestamp:
- 11/22/07 22:25:30 (1 year ago)
- Files:
-
- trunk/lib/jelix-scripts/commands/createform.cmd.php (modified) (1 diff)
- trunk/lib/jelix-scripts/commands/createform.cmd.php (modified) (1 diff)
- trunk/lib/jelix-www/js/jforms.js (modified) (1 diff)
- trunk/lib/jelix-www/js/jforms.js (modified) (1 diff)
- trunk/lib/jelix/forms/jFormsCompiler.class.php (modified) (1 diff)
- trunk/lib/jelix/forms/jFormsCompiler.class.php (modified) (1 diff)
- trunk/testapp/modules/jelix_tests/tests/jforms.compiler.html.php (modified) (3 diffs)
- trunk/testapp/modules/jelix_tests/tests/jforms.compiler.html.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/jelix-scripts/commands/createform.cmd.php
r641 r650 88 88 if($property->required) 89 89 $attr.=' required="true"'; 90 90 91 91 if($property->defaultValue !== null) 92 92 $attr.=' defaultvalue="'.htmlspecialchars($property->defaultValue).'"'; 93 93 94 if($property->maxlength !== null) 95 $attr.=' maxlength="'.$property->maxlength.'"'; 96 97 if($property->minlength !== null) 98 $attr.=' minlength="'.$property->minlength.'"'; 99 94 100 //if(false) 95 101 // $attr.=' defaultvalue=""'; trunk/lib/jelix-scripts/commands/createform.cmd.php
r641 r650 88 88 if($property->required) 89 89 $attr.=' required="true"'; 90 90 91 91 if($property->defaultValue !== null) 92 92 $attr.=' defaultvalue="'.htmlspecialchars($property->defaultValue).'"'; 93 93 94 if($property->maxlength !== null) 95 $attr.=' maxlength="'.$property->maxlength.'"'; 96 97 if($property->minlength !== null) 98 $attr.=' minlength="'.$property->minlength.'"'; 99 94 100 //if(false) 95 101 // $attr.=' defaultvalue=""'; trunk/lib/jelix-www/js/jforms.js
r647 r650 308 308 this.isConfirmField = false; 309 309 this.confirmFieldOf = ''; 310 this.minLength = -1; 311 this.maxLength = -1; 310 312 } 311 313 trunk/lib/jelix-www/js/jforms.js
r647 r650 308 308 this.isConfirmField = false; 309 309 this.confirmFieldOf = ''; 310 this.minLength = -1; 311 this.maxLength = -1; 310 312 } 311 313 trunk/lib/jelix/forms/jFormsCompiler.class.php
r632 r650 142 142 } 143 143 $source[]='$ctrl->defaultValue=\''.str_replace('\'','\\\'',(string)$control['defaultvalue']) .'\';'; 144 } 145 // minlength support 146 if(isset($control['minlength'])){ 147 if($controltype != 'textarea' && 148 ($controltype != 'input'|| ($controltype == 'input' && isset($control['type']) && $control['type'] != 'string'))){ 149 throw new jException('jelix~formserr.attribute.not.allowed',array('minlength',$controltype,$this->sourceFile)); 150 } 151 $source[]='$ctrl->datasource->addFacet(\'minLength\','.intval((string)$control['minlength']).');'; 152 } 153 // maxlength support 154 if(isset($control['maxlength'])){ 155 if($controltype != 'textarea' && 156 ($controltype != 'input'|| ($controltype == 'input' && isset($control['type']) && $control['type'] != 'string'))){ 157 throw new jException('jelix~formserr.attribute.not.allowed',array('maxlength',$controltype,$this->sourceFile)); 158 } 159 $source[]='$ctrl->datasource->addFacet(\'maxLength\','.intval((string)$control['maxlength']).');'; 144 160 } 145 161 trunk/lib/jelix/forms/jFormsCompiler.class.php
r632 r650 142 142 } 143 143 $source[]='$ctrl->defaultValue=\''.str_replace('\'','\\\'',(string)$control['defaultvalue']) .'\';'; 144 } 145 // minlength support 146 if(isset($control['minlength'])){ 147 if($controltype != 'textarea' && 148 ($controltype != 'input'|| ($controltype == 'input' && isset($control['type']) && $control['type'] != 'string'))){ 149 throw new jException('jelix~formserr.attribute.not.allowed',array('minlength',$controltype,$this->sourceFile)); 150 } 151 $source[]='$ctrl->datasource->addFacet(\'minLength\','.intval((string)$control['minlength']).');'; 152 } 153 // maxlength support 154 if(isset($control['maxlength'])){ 155 if($controltype != 'textarea' && 156 ($controltype != 'input'|| ($controltype == 'input' && isset($control['type']) && $control['type'] != 'string'))){ 157 throw new jException('jelix~formserr.attribute.not.allowed',array('maxlength',$controltype,$this->sourceFile)); 158 } 159 $source[]='$ctrl->datasource->addFacet(\'maxLength\','.intval((string)$control['maxlength']).');'; 144 160 } 145 161 trunk/testapp/modules/jelix_tests/tests/jforms.compiler.html.php
r632 r650 266 266 64=>'<textarea ref="nom" rows="15" cols="20" xmlns="http://jelix.org/ns/forms/1.0"> 267 267 <label>Votre nom</label> 268 </textarea>' 268 </textarea>', 269 65=>'<input ref="nom" maxlength="3" xmlns="http://jelix.org/ns/forms/1.0"> 270 <label>Votre nom</label> 271 </input>', 269 272 ); 270 273 … … 614 617 $ctrl->rows=15; 615 618 $ctrl->cols=20; 616 $this->addControl($ctrl);' 619 $this->addControl($ctrl);', 620 65=>'$ctrl= new jFormsControlinput(\'nom\'); 621 $ctrl->datasource->addFacet(\'maxLength\',3); 622 $ctrl->label=\'Votre nom\'; 623 $this->addControl($ctrl);', 617 624 ); 618 625 … … 959 966 $js.="jForms.tControl.errRequired=\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.required\',$label))."\';\n"; 960 967 $js.="jForms.tControl.errInvalid =\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.invalid\', $label))."\';\n"; 961 $js.="jForms.tForm.addControl( jForms.tControl);\n";' 968 $js.="jForms.tForm.addControl( jForms.tControl);\n";', 969 65=>'$label = \'Votre nom\'; 970 $js.="jForms.tControl = new jFormsControl(\'nom\', \'".str_replace("\'","\\\'",$label)."\', \'string\');\n"; 971 $js.="jForms.tControl.maxLength = 3;\n"; 972 $js.="jForms.tControl.errRequired=\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.required\',$label))."\';\n"; 973 $js.="jForms.tControl.errInvalid =\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.invalid\', $label))."\';\n"; 974 $js.="jForms.tForm.addControl( jForms.tControl);\n";', 962 975 ); 963 976 trunk/testapp/modules/jelix_tests/tests/jforms.compiler.html.php
r632 r650 266 266 64=>'<textarea ref="nom" rows="15" cols="20" xmlns="http://jelix.org/ns/forms/1.0"> 267 267 <label>Votre nom</label> 268 </textarea>' 268 </textarea>', 269 65=>'<input ref="nom" maxlength="3" xmlns="http://jelix.org/ns/forms/1.0"> 270 <label>Votre nom</label> 271 </input>', 269 272 ); 270 273 … … 614 617 $ctrl->rows=15; 615 618 $ctrl->cols=20; 616 $this->addControl($ctrl);' 619 $this->addControl($ctrl);', 620 65=>'$ctrl= new jFormsControlinput(\'nom\'); 621 $ctrl->datasource->addFacet(\'maxLength\',3); 622 $ctrl->label=\'Votre nom\'; 623 $this->addControl($ctrl);', 617 624 ); 618 625 … … 959 966 $js.="jForms.tControl.errRequired=\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.required\',$label))."\';\n"; 960 967 $js.="jForms.tControl.errInvalid =\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.invalid\', $label))."\';\n"; 961 $js.="jForms.tForm.addControl( jForms.tControl);\n";' 968 $js.="jForms.tForm.addControl( jForms.tControl);\n";', 969 65=>'$label = \'Votre nom\'; 970 $js.="jForms.tControl = new jFormsControl(\'nom\', \'".str_replace("\'","\\\'",$label)."\', \'string\');\n"; 971 $js.="jForms.tControl.maxLength = 3;\n"; 972 $js.="jForms.tControl.errRequired=\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.required\',$label))."\';\n"; 973 $js.="jForms.tControl.errInvalid =\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.invalid\', $label))."\';\n"; 974 $js.="jForms.tForm.addControl( jForms.tControl);\n";', 962 975 ); 963 976
