Ticket #635: 635-jForms-add-support-of-the-required-attribute-on-checkebox.2.diff
| File 635-jForms-add-support-of-the-required-attribute-on-checkebox.2.diff, 7.0 kB (added by Julien, 4 months ago) |
|---|
-
testapp/modules/jelix_tests/tests/jforms.compiler_1_1.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, Julien Issler 7 7 * @copyright 2007-2008 Jouanneau laurent 8 8 * @copyright 2007 Loic Mathaud, 2008 Dominique Papin 9 * @copyright 2008 Julien Issler 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 */ … … 899 900 array('type','checkbox','myfile') 900 901 ), 901 902 array( 902 '<checkbox ref="nom" xmlns="http://jelix.org/ns/forms/1.1" required="true">903 <label>Votre nom</label>904 </checkbox>',905 'jelix~formserr.attribute.not.allowed',906 array('required','checkbox','myfile')907 ),908 array(909 903 '<secret ref="pwd" defaultvalue="toto" xmlns="http://jelix.org/ns/forms/1.1"> 910 904 <label>Votre mot de passe</label> 911 905 </secret>', -
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 6 * @contributor Loic Mathaud, Julien Issler 7 7 * @copyright 2007-2008 Jouanneau laurent 8 8 * @copyright 2007 Loic Mathaud 9 * @copyright 2008 Julien Issler 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 */ … … 700 701 array('type','checkbox','myfile') 701 702 ), 702 703 array( 703 '<checkbox ref="nom" xmlns="http://jelix.org/ns/forms/1.0" required="true">704 <label>Votre nom</label>705 </checkbox>',706 'jelix~formserr.attribute.not.allowed',707 array('required','checkbox','myfile')708 ),709 array(710 704 '<secret ref="pwd" defaultvalue="toto" xmlns="http://jelix.org/ns/forms/1.0"> 711 705 <label>Votre mot de passe</label> 712 706 </secret>', -
testapp/modules/jelix_tests/tests/jforms.check_datas.html_cli.php
old new 3 3 * @package testapp 4 4 * @subpackage unittest module 5 5 * @author Jouanneau Laurent 6 * @contributor 6 * @contributor Julien Issler 7 7 * @copyright 2007-2008 Jouanneau laurent 8 * @copyright 2008 Julien Issler 8 9 * @link http://www.jelix.org 9 10 * @licence GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html 10 11 */ … … 89 90 $this->assertTrue($this->form->check()); 90 91 $this->form->setData('nom','1'); 91 92 $this->assertTrue($this->form->check()); 93 94 $ctrl->required = true; 95 $this->form->setData('nom',null); 96 $this->assertFalse($this->form->check()); 97 $this->form->setData('nom',''); 98 $this->assertFalse($this->form->check()); 99 $this->form->setData('nom','on'); 100 $this->assertTrue($this->form->check()); 101 $this->form->setData('nom','0'); 102 $this->assertFalse($this->form->check()); 103 $this->form->setData('nom','1'); 104 $this->assertTrue($this->form->check()); 92 105 } 93 106 94 107 function testCheckboxes() { -
lib/jelix/forms/jFormsCompiler_jf_1_0.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, Julien Issler 7 7 * @contributor Uriel Corfa Emotic SARL 8 8 * @copyright 2006-2008 Laurent Jouanneau 9 9 * @copyright 2007 Loic Mathaud, 2007 Dominique Papin 10 10 * @copyright 2007 Emotic SARL 11 * @copyright 2008 Julien Issler 11 12 * @link http://www.jelix.org 12 13 * @licence GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html 13 14 */ … … 185 186 $source[]='$ctrl->valueOnUncheck=\''.str_replace("'","\\'", $attributes['valueonuncheck']) ."';"; 186 187 unset($attributes['valueonuncheck']); 187 188 } 189 $this->attrRequired($source, $attributes); 188 190 return false; 189 191 } 190 192 -
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, Julien Issler 7 7 * @copyright 2006-2008 Laurent Jouanneau, 2007 Dominique Papin 8 8 * @copyright 2007 Loic Mathaud 9 * @copyright 2008 Julien Issler 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 */ … … 222 223 223 224 function check(){ 224 225 $value = $this->container->data[$this->ref]; 226 if($this->required && $value == $this->valueOnUncheck) 227 return $this->container->errors[$this->ref] = jForms::ERRDATA_REQUIRED; 225 228 if($value != $this->valueOnCheck && $value != $this->valueOnUncheck) 226 229 return $this->container->errors[$this->ref] = jForms::ERRDATA_INVALID; 227 230 return null; -
lib/jelix/docs/ns/jforms_1.0.rng
old new 126 126 <element name="checkbox"> 127 127 <ref name="control.common" /> 128 128 <ref name="UI.attr.readonly" /> 129 <ref name="UI.attr.required" /> 129 130 <ref name="UI.attr.defaultvalue" /> 130 131 <optional><attribute name="valueoncheck" /></optional> 131 132 <optional><attribute name="valueonuncheck" /></optional> -
lib/jelix/docs/ns/jforms_1.1.rng
old new 153 153 <element name="checkbox"> 154 154 <ref name="control.common" /> 155 155 <ref name="UI.attr.readonly" /> 156 <ref name="UI.attr.required" /> 156 157 <ref name="UI.attr.defaultvalue" /> 157 158 <optional><attribute name="valueoncheck" /></optional> 158 159 <optional><attribute name="valueonuncheck" /></optional>
