Changeset 1063
- Timestamp:
- 08/26/08 00:29:07 (3 months ago)
- Files:
-
- trunk/lib/jelix/docs/ns/jforms_1.1.rng (modified) (1 diff)
- trunk/lib/jelix/forms/jFormsCompiler_jf_1_1.class.php (modified) (1 diff)
- trunk/lib/jelix/forms/jFormsControl.class.php (modified) (1 diff)
- trunk/lib/jelix/plugins/jforms/html/html.jformsbuilder.php (modified) (1 diff)
- trunk/testapp/modules/jelix_tests/tests/jforms.compiler_1_1.html_cli.php (modified) (2 diffs)
- trunk/testapp/modules/jelix_tests/tests/jforms.htmlbuilder.html_cli.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/jelix/docs/ns/jforms_1.1.rng
r1062 r1063 118 118 <ref name="UI.attr.readonly" /> 119 119 <ref name="UI.attr.required" /> 120 <ref name="attr.length" /> 120 121 <ref name="attr.size" /> 121 122 <optional> trunk/lib/jelix/forms/jFormsCompiler_jf_1_1.class.php
r1053 r1063 83 83 } 84 84 85 protected function generateSecret(&$source, $control, &$attributes) { 86 if(isset($attributes['minlength'])){ 87 $source[]='$ctrl->datatype->addFacet(\'minLength\','.intval($attributes['minlength']).');'; 88 unset($attributes['minlength']); 89 } 90 if(isset($attributes['maxlength'])){ 91 $source[]='$ctrl->datatype->addFacet(\'maxLength\','.intval($attributes['maxlength']).');'; 92 unset($attributes['maxlength']); 93 } 94 return parent::generateSecret($source, $control, $attributes); 95 } 96 85 97 protected function generateHtmleditor(&$source, $control, &$attributes) { 86 98 $this->_generateTextareaHtmlEditor($source, $control, $attributes); trunk/lib/jelix/forms/jFormsControl.class.php
r1053 r1063 180 180 public $size=0; 181 181 182 function check(){183 if ($this->container->data[$this->ref] == '' && $this->required) {184 return $this->container->errors[$this->ref] = jForms::ERRDATA_REQUIRED;185 }186 return null;187 }188 182 function getDisplayValue($value){ 189 183 return str_repeat("*", strlen($value)); trunk/lib/jelix/plugins/jforms/html/html.jformsbuilder.php
r1053 r1063 445 445 protected function outputSecret($ctrl, $id, $class, $readonly, $hint) { 446 446 $size = ($ctrl->size == 0?'': ' size="'.$ctrl->size.'"'); 447 echo '<input type="password"',$id,$readonly,$hint,$class,$size,' value="',htmlspecialchars($this->_form->getData($ctrl->ref)),'"',$this->_endt; 447 $maxl = $ctrl->datatype->getFacet('maxLength'); 448 if($maxl !== null) 449 $maxl = ' maxlength="'.$maxl.'"'; 450 else 451 $maxl = ''; 452 echo '<input type="password"',$id,$readonly,$hint,$class,$size,$maxl,' value="',htmlspecialchars($this->_form->getData($ctrl->ref)),'"',$this->_endt; 448 453 } 449 454 trunk/testapp/modules/jelix_tests/tests/jforms.compiler_1_1.html_cli.php
r1062 r1063 375 375 <datasource dao="foo" method="bar" labelproperty="baz,biz" labelseparator=" - " valueproperty="plop" criteriafrom="prenom,nom"/> 376 376 </menulist>', 377 377 83=>'<secret ref="pwd" minlength="5" maxlength="10" xmlns="http://jelix.org/ns/forms/1.1"> 378 <label>Votre mot de passe</label> 379 <confirm>confirmez</confirm> 380 </secret>', 378 381 ); 379 382 … … 828 831 $ctrl->datasource = new jFormsDaoDatasource(\'foo\',\'bar\',\'baz,biz\',\'plop\',\'\',null,\'prenom,nom\',\' - \'); 829 832 $this->addControl($ctrl);', 833 83=>'$ctrl= new jFormsControlsecret(\'pwd\'); 834 $ctrl->datatype->addFacet(\'minLength\',5); 835 $ctrl->datatype->addFacet(\'maxLength\',10); 836 $ctrl->label=\'Votre mot de passe\'; 837 $ctrl2 = new jFormsControlSecretConfirm(\'pwd_confirm\'); 838 $ctrl2->primarySecret = \'pwd\'; 839 $ctrl2->label=\'confirmez\'; 840 $ctrl2->required = $ctrl->required; 841 $this->addControl($ctrl); 842 $this->addControl($ctrl2);', 830 843 ); 831 844 trunk/testapp/modules/jelix_tests/tests/jforms.htmlbuilder.html_cli.php
r1050 r1063 1003 1003 jForms.tForm.addControl(jForms.tControl); 1004 1004 ', $this->builder->getJsContent()); 1005 1006 $ctrl->datatype->addFacet('minLength',5); 1007 $ctrl->datatype->addFacet('maxLength',10); 1008 ob_start();$this->builder->outputControl($ctrl);$out = ob_get_clean(); 1009 $this->assertEqualOrDiff('<input type="password" name="passwd" id="'.$this->formname.'_passwd" readonly="readonly" title="ceci est un tooltip" class=" jforms-readonly" maxlength="10" value="laurent"/>', $out); 1010 $this->assertEqualOrDiff('jForms.tControl = new jFormsControlString(\'passwd\', \'mot de passe\'); 1011 jForms.tControl.maxLength = \'10\'; 1012 jForms.tControl.minLength = \'5\'; 1013 jForms.tControl.errInvalid=\'La saisie de "mot de passe" est invalide\'; 1014 jForms.tForm.addControl(jForms.tControl); 1015 ', $this->builder->getJsContent()); 1016 1005 1017 1006 1018 }
