developer.jelix.org is not used any more and exists only for history. Post new tickets on the Github account.
developer.jelix.org n'est plus utilisée, et existe uniquement pour son historique. Postez les nouveaux tickets sur le compte github.

Ticket #635: 635-jForms-add-support-of-the-required-attribute-on-checkebox.diff

File 635-jForms-add-support-of-the-required-attribute-on-checkebox.diff, 2.2 KB (added by Julien, 13 years ago)
  • lib/jelix/forms/jFormsCompiler_jf_1_0.class.php

     
    33* @package    jelix
    44* @subpackage forms
    55* @author     Laurent Jouanneau
    6 * @contributor Loic Mathaud, Dominique Papin
     6* @contributor Loic Mathaud, Dominique Papin, Julien Issler
    77* @contributor Uriel Corfa Emotic SARL
    88* @copyright   2006-2008 Laurent Jouanneau
    99* @copyright   2007 Loic Mathaud, 2007 Dominique Papin
    1010* @copyright   2007 Emotic SARL
     11* @copyright   2008 Julien Issler
    1112* @link        http://www.jelix.org
    1213* @licence    GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html
    1314*/
     
    185186            $source[]='$ctrl->valueOnUncheck=\''.str_replace("'","\\'", $attributes['valueonuncheck']) ."';";
    186187            unset($attributes['valueonuncheck']);
    187188        }
     189        $this->attrRequired($source, $attributes);
    188190        return false;
    189191    }
    190192
  • lib/jelix/forms/jFormsControl.class.php

     
    33* @package     jelix
    44* @subpackage  forms
    55* @author      Laurent Jouanneau
    6 * @contributor Loic Mathaud, Dominique Papin
     6* @contributor Loic Mathaud, Dominique Papin, Julien Issler
    77* @copyright   2006-2008 Laurent Jouanneau, 2007 Dominique Papin
    88* @copyright   2007 Loic Mathaud
     9* @copyright   2008 Julien Issler
    910* @link        http://www.jelix.org
    1011* @licence     http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public Licence, see LICENCE file
    1112*/
     
    222223
    223224    function check(){
    224225        $value = $this->container->data[$this->ref];
     226        if($this->required && $value == $this->valueOnUncheck)
     227            return $this->container->errors[$this->ref] = jForms::ERRDATA_REQUIRED;
    225228        if($value != $this->valueOnCheck && $value != $this->valueOnUncheck)
    226229            return $this->container->errors[$this->ref] = jForms::ERRDATA_INVALID;
    227230        return null;