Ticket #556: patch_minmaxlength_556_v2.2.diff

File patch_minmaxlength_556_v2.2.diff, 7.1 kB (added by mike, 4 months ago)

Patch V2. Cette fois c'est la bonne ....

  • testapp/modules/jelix_tests/tests/jforms.compiler.html_cli.php

    old new  
    33* @package     testapp 
    44* @subpackage  unittest module 
    55* @author      Jouanneau Laurent 
    6 * @contributor Loic Mathaud, Dominique Papin 
     6* @contributor Loic Mathaud, Dominique Papin, Mickaël Fradin 
    77* @copyright   2007-2008 Jouanneau laurent 
    88* @copyright   2007 Loic Mathaud, Dominique Papin 
     9* @copyright   2008 Mickaël Fradin 
    910* @link        http://www.jelix.org 
    1011* @licence     GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html 
    1112*/ 
     
    378379    <label>Votre nom</label> 
    379380    <datasource class="jelix_tests~mydatasource"/> 
    380381</menulist>', 
    381  
     38287=>'<secret ref="pwd" size="10" minlength="6" xmlns="http://jelix.org/ns/forms/1.0"> 
     383    <label>Votre mot de passe</label> 
     384</secret>', 
     38588=>'<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>', 
    382389    ); 
    383390 
    384391    protected $_PhpControls = array( 
     
    816823if ($datasource instanceof jIFormsDatasource){$ctrl->datasource=$datasource;} 
    817824else{$ctrl->datasource=new jFormsStaticDatasource();} 
    818825$this->addControl($ctrl);', 
    819  
     82687=>'$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);', 
     83188=>'$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);', 
    820844); 
    821845 
    822846 
     
    12691293$js.="jForms.tControl.errRequired=\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.required\',$label))."\';\\n"; 
    12701294$js.="jForms.tControl.errInvalid =\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.invalid\', $label))."\';\\n"; 
    12711295$js.="jForms.tForm.addControl( jForms.tControl);\\n";', 
     129687=>'$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";', 
     130288=>'$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";', 
    12721315    ); 
    12731316 
    12741317    function testPhpControl10(){ 
  • lib/jelix/forms/jFormsCompiler_jf_1_0.class.php

    old new  
    55* @author     Laurent Jouanneau 
    66* @contributor Loic Mathaud, Dominique Papin 
    77* @contributor Uriel Corfa Emotic SARL 
     8* @contributor Mickaël Fradin 
    89* @copyright   2006-2008 Laurent Jouanneau 
    910* @copyright   2007 Loic Mathaud, 2007 Dominique Papin 
    1011* @copyright   2007 Emotic SARL 
     12* @copyright   2008 Mickaël Fradin 
    1113* @link        http://www.jelix.org 
    1214* @licence    GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html 
    1315*/ 
     
    241243        $this->readLabel($source, $control, 'secret'); 
    242244        list($alertInvalid, $alertRequired)=$this->readHelpHintAlert($source, $control); 
    243245        $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        } 
    244254 
    245255        if(isset($control->confirm)) { 
    246256            $label=''; 
  • lib/jelix/forms/jFormsControl.class.php

    old new  
    33* @package     jelix 
    44* @subpackage  forms 
    55* @author      Laurent Jouanneau 
    6 * @contributor Loic Mathaud, Dominique Papin 
     6* @contributor Loic Mathaud, Dominique Papin, Mickaël Fradin 
    77* @copyright   2006-2008 Laurent Jouanneau, 2007 Dominique Papin 
    88* @copyright   2007 Loic Mathaud 
     9* @copyright   2008 Mickaël Fradin 
    910* @link        http://www.jelix.org 
    1011* @licence     http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public Licence, see LICENCE file 
    1112*/ 
     
    135136    public $size=0; 
    136137 
    137138    function check($form){ 
    138         if ($form->getContainer()->data[$this->ref] == '' && $this->required) { 
     139        $value = $form->getContainer()->data[$this->ref]; 
     140        if ($value == '' && $this->required) 
    139141            return jForms::ERRDATA_REQUIRED; 
    140         } 
     142        if (!$this->datatype->check($value)) 
     143            return jForms::ERRDATA_INVALID; 
    141144        return null; 
    142145    } 
    143146    function getDisplayValue($value){ 
  • lib/jelix/CREDITS

    old new  
    107107Mickaël Fradin (aka mike) 
    108108 - improvements in the jtpl plugin: formcontrols (#223) 
    109109 - added style feature in the meta_html plugin (#553) 
     110 - added minlength and maxlength support on secret field in jforms (#556) 
    110111 
    111112Olivier Gambier (aka d-m-p) 
    112113 - code reviewer, bug fixes 
Download in other formats: Original Format