Ticket #556: patch_minmaxlength_556_v2.2.diff
| File patch_minmaxlength_556_v2.2.diff, 7.1 kB (added by mike, 4 months ago) |
|---|
-
testapp/modules/jelix_tests/tests/jforms.compiler.html_cli.php
old new 3 3 * @package testapp 4 4 * @subpackage unittest module 5 5 * @author Jouanneau Laurent 6 * @contributor Loic Mathaud, Dominique Papin 6 * @contributor Loic Mathaud, Dominique Papin, Mickaël Fradin 7 7 * @copyright 2007-2008 Jouanneau laurent 8 8 * @copyright 2007 Loic Mathaud, Dominique Papin 9 * @copyright 2008 Mickaël Fradin 9 10 * @link http://www.jelix.org 10 11 * @licence GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html 11 12 */ … … 378 379 <label>Votre nom</label> 379 380 <datasource class="jelix_tests~mydatasource"/> 380 381 </menulist>', 381 382 87=>'<secret ref="pwd" size="10" minlength="6" xmlns="http://jelix.org/ns/forms/1.0"> 383 <label>Votre mot de passe</label> 384 </secret>', 385 88=>'<secret ref="pwd" size="10" minlength="6" maxlength="20" xmlns="http://jelix.org/ns/forms/1.0"> 386 <label>Votre mot de passe</label> 387 <confirm>confirmez</confirm> 388 </secret>', 382 389 ); 383 390 384 391 protected $_PhpControls = array( … … 816 823 if ($datasource instanceof jIFormsDatasource){$ctrl->datasource=$datasource;} 817 824 else{$ctrl->datasource=new jFormsStaticDatasource();} 818 825 $this->addControl($ctrl);', 819 826 87=>'$ctrl= new jFormsControlsecret(\'pwd\'); 827 $ctrl->label=\'Votre mot de passe\'; 828 $ctrl->size=10; 829 $ctrl->datatype->addFacet(\'minLength\',6); 830 $this->addControl($ctrl);', 831 88=>'$ctrl= new jFormsControlsecret(\'pwd\'); 832 $ctrl->label=\'Votre mot de passe\'; 833 $ctrl->size=10; 834 $ctrl->datatype->addFacet(\'minLength\',6); 835 $ctrl->datatype->addFacet(\'maxLength\',20); 836 $ctrl2 = new jFormsControlSecretConfirm(\'pwd_confirm\'); 837 $ctrl2->primarySecret = \'pwd\'; 838 $ctrl2->label=\'confirmez\'; 839 $ctrl2->required = $ctrl->required; 840 $ctrl2->readonly = $ctrl->readonly; 841 $ctrl2->size=$ctrl->size; 842 $this->addControl($ctrl); 843 $this->addControl($ctrl2);', 820 844 ); 821 845 822 846 … … 1269 1293 $js.="jForms.tControl.errRequired=\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.required\',$label))."\';\\n"; 1270 1294 $js.="jForms.tControl.errInvalid =\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.invalid\', $label))."\';\\n"; 1271 1295 $js.="jForms.tForm.addControl( jForms.tControl);\\n";', 1296 87=>'$label = \'Votre mot de passe\'; 1297 $js.="jForms.tControl = new jFormsControl(\'pwd\', \'".str_replace("\'","\\\'",$label)."\', \'string\');\n"; 1298 $js.="jForms.tControl.minLength = 6;\n"; 1299 $js.="jForms.tControl.errRequired=\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.required\',$label))."\';\n"; 1300 $js.="jForms.tControl.errInvalid =\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.invalid\', $label))."\';\n"; 1301 $js.="jForms.tForm.addControl( jForms.tControl);\n";', 1302 88=>'$label = \'Votre mot de passe\'; 1303 $js.="jForms.tControl = new jFormsControl(\'pwd\', \'".str_replace("\'","\\\'",$label)."\', \'string\');\n"; 1304 $label2 = \'confirmez\'; 1305 $js.="jForms.tControl2 = new jFormsControl(\'pwd_confirm\', \'".str_replace("\'","\\\'",$label2)."\', \'string\');\n"; 1306 $js.="jForms.tControl.maxLength = 20;\n"; 1307 $js.="jForms.tControl.minLength = 6;\n"; 1308 $js.="jForms.tControl.errRequired=\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.required\',$label))."\';\n"; 1309 $js.="jForms.tControl.errInvalid =\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.invalid\', $label))."\';\n"; 1310 $js.="jForms.tControl2.errRequired=\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.required\',$label2))."\';\n"; 1311 $js.="jForms.tControl2.errInvalid =\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.invalid\', $label2))."\';\n"; 1312 $js.="jForms.tForm.addControl( jForms.tControl);\n"; 1313 $js.="jForms.tControl2.isConfirmField=true;\njForms.tControl2.confirmFieldOf=\'pwd\';\n"; 1314 $js.="jForms.tForm.addControl( jForms.tControl2);\n";', 1272 1315 ); 1273 1316 1274 1317 function testPhpControl10(){ -
lib/jelix/forms/jFormsCompiler_jf_1_0.class.php
old new 5 5 * @author Laurent Jouanneau 6 6 * @contributor Loic Mathaud, Dominique Papin 7 7 * @contributor Uriel Corfa Emotic SARL 8 * @contributor Mickaël Fradin 8 9 * @copyright 2006-2008 Laurent Jouanneau 9 10 * @copyright 2007 Loic Mathaud, 2007 Dominique Papin 10 11 * @copyright 2007 Emotic SARL 12 * @copyright 2008 Mickaël Fradin 11 13 * @link http://www.jelix.org 12 14 * @licence GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html 13 15 */ … … 241 243 $this->readLabel($source, $control, 'secret'); 242 244 list($alertInvalid, $alertRequired)=$this->readHelpHintAlert($source, $control); 243 245 $this->attrSize($source, $attributes); 246 if(isset($attributes['minlength'])) { 247 $source[]='$ctrl->datatype->addFacet(\'minLength\','.intval($attributes['minlength']).');'; 248 unset($attributes['minlength']); 249 } 250 if(isset($attributes['maxlength'])) { 251 $source[]='$ctrl->datatype->addFacet(\'maxLength\','.intval($attributes['maxlength']).');'; 252 unset($attributes['maxlength']); 253 } 244 254 245 255 if(isset($control->confirm)) { 246 256 $label=''; -
lib/jelix/forms/jFormsControl.class.php
old new 3 3 * @package jelix 4 4 * @subpackage forms 5 5 * @author Laurent Jouanneau 6 * @contributor Loic Mathaud, Dominique Papin 6 * @contributor Loic Mathaud, Dominique Papin, Mickaël Fradin 7 7 * @copyright 2006-2008 Laurent Jouanneau, 2007 Dominique Papin 8 8 * @copyright 2007 Loic Mathaud 9 * @copyright 2008 Mickaël Fradin 9 10 * @link http://www.jelix.org 10 11 * @licence http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public Licence, see LICENCE file 11 12 */ … … 135 136 public $size=0; 136 137 137 138 function check($form){ 138 if ($form->getContainer()->data[$this->ref] == '' && $this->required) { 139 $value = $form->getContainer()->data[$this->ref]; 140 if ($value == '' && $this->required) 139 141 return jForms::ERRDATA_REQUIRED; 140 } 142 if (!$this->datatype->check($value)) 143 return jForms::ERRDATA_INVALID; 141 144 return null; 142 145 } 143 146 function getDisplayValue($value){ -
lib/jelix/CREDITS
old new 107 107 Mickaël Fradin (aka mike) 108 108 - improvements in the jtpl plugin: formcontrols (#223) 109 109 - added style feature in the meta_html plugin (#553) 110 - added minlength and maxlength support on secret field in jforms (#556) 110 111 111 112 Olivier Gambier (aka d-m-p) 112 113 - code reviewer, bug fixes
