Changeset 702

Show
Ignore:
Timestamp:
12/15/07 15:28:20 (1 year ago)
Author:
laurentj
Message:

ticket #258: added support of reset tag in jforms. p=Dominique Papin

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/build/manifests/jelix-lib.mn

    r696 r702  
    371371  function.ctrl_value.php 
    372372  function.formsubmit.php 
     373  function.formreset.php 
    373374  function.pagelinks.php 
    374375 
  • trunk/build/manifests/jelix-lib.mn

    r696 r702  
    371371  function.ctrl_value.php 
    372372  function.formsubmit.php 
     373  function.formreset.php 
    373374  function.pagelinks.php 
    374375 
  • trunk/lib/jelix/core-modules/jelix/locales/en_EN/formserr.ISO-8859-1.properties

    r580 r702  
    11tag.missing=(800) %1$s is missing (file %2$s) 
    2 unknow.tag=(801) unknow tag %1$s  (file %2$s) 
     2unknow.tag=(801) unknown tag %1$s  (file %2$s) 
    33attribute.missing=(802) attribut %1$s is missing on %2$s (file %3$s) 
    44attribute.not.allowed=(803) attribut %1$s not allowed on %2$s (file %3$s) 
    5 datatype.unknow=(804) unknow datatype %1$s  on %2$s (file %3$s) 
     5datatype.unknow=(804) unknown datatype %1$s  on %2$s (file %3$s) 
    66invalid.xml.file=(805) invalid xml syntax in jforms file (file %s) 
    77selected.attribute.not.allowed=(806)"selected" attribute on <item> is not allowed when using defaultvalue attribute or <defaultvalues> (file %s) 
     
    1616invalid.upload.control.name = (815) The given control name "%s" is invalid or the corresponding control is not an upload (form=%s) 
    1717content.missing=(816) content of %1$s tag is missing (file %2$s) 
     18notunique.tag=(817) tag %1$s must be unique (file %2$s) 
    1819 
    1920js.err.invalid= "%s" field is invalid 
  • trunk/lib/jelix/core-modules/jelix/locales/en_EN/formserr.ISO-8859-1.properties

    r580 r702  
    11tag.missing=(800) %1$s is missing (file %2$s) 
    2 unknow.tag=(801) unknow tag %1$s  (file %2$s) 
     2unknow.tag=(801) unknown tag %1$s  (file %2$s) 
    33attribute.missing=(802) attribut %1$s is missing on %2$s (file %3$s) 
    44attribute.not.allowed=(803) attribut %1$s not allowed on %2$s (file %3$s) 
    5 datatype.unknow=(804) unknow datatype %1$s  on %2$s (file %3$s) 
     5datatype.unknow=(804) unknown datatype %1$s  on %2$s (file %3$s) 
    66invalid.xml.file=(805) invalid xml syntax in jforms file (file %s) 
    77selected.attribute.not.allowed=(806)"selected" attribute on <item> is not allowed when using defaultvalue attribute or <defaultvalues> (file %s) 
     
    1616invalid.upload.control.name = (815) The given control name "%s" is invalid or the corresponding control is not an upload (form=%s) 
    1717content.missing=(816) content of %1$s tag is missing (file %2$s) 
     18notunique.tag=(817) tag %1$s must be unique (file %2$s) 
    1819 
    1920js.err.invalid= "%s" field is invalid 
  • trunk/lib/jelix/core-modules/jelix/locales/en_EN/formserr.UTF-8.properties

    r580 r702  
    11tag.missing=(800) %1$s is missing (file %2$s) 
    2 unknow.tag=(801) unknow tag %1$s  (file %2$s) 
     2unknow.tag=(801) unknown tag %1$s  (file %2$s) 
    33attribute.missing=(802) attribut %1$s is missing on %2$s (file %3$s) 
    44attribute.not.allowed=(803) attribut %1$s not allowed on %2$s (file %3$s) 
    5 datatype.unknow=(804) unknow datatype %1$s  on %2$s (file %3$s) 
     5datatype.unknow=(804) unknown datatype %1$s  on %2$s (file %3$s) 
    66invalid.xml.file=(805) invalid xml syntax in jforms file (file %s) 
    77selected.attribute.not.allowed=(806)"selected" attribute on <item> is not allowed when using defaultvalue attribute or <defaultvalues> (file %s) 
     
    1616invalid.upload.control.name = (815) The given control name "%s" is invalid or the corresponding control is not an upload (form=%s) 
    1717content.missing=(816) content of %1$s tag is missing (file %2$s) 
     18notunique.tag=(817) tag %1$s must be unique (file %2$s) 
    1819 
    1920js.err.invalid= "%s" field is invalid 
  • trunk/lib/jelix/core-modules/jelix/locales/en_EN/formserr.UTF-8.properties

    r580 r702  
    11tag.missing=(800) %1$s is missing (file %2$s) 
    2 unknow.tag=(801) unknow tag %1$s  (file %2$s) 
     2unknow.tag=(801) unknown tag %1$s  (file %2$s) 
    33attribute.missing=(802) attribut %1$s is missing on %2$s (file %3$s) 
    44attribute.not.allowed=(803) attribut %1$s not allowed on %2$s (file %3$s) 
    5 datatype.unknow=(804) unknow datatype %1$s  on %2$s (file %3$s) 
     5datatype.unknow=(804) unknown datatype %1$s  on %2$s (file %3$s) 
    66invalid.xml.file=(805) invalid xml syntax in jforms file (file %s) 
    77selected.attribute.not.allowed=(806)"selected" attribute on <item> is not allowed when using defaultvalue attribute or <defaultvalues> (file %s) 
     
    1616invalid.upload.control.name = (815) The given control name "%s" is invalid or the corresponding control is not an upload (form=%s) 
    1717content.missing=(816) content of %1$s tag is missing (file %2$s) 
     18notunique.tag=(817) tag %1$s must be unique (file %2$s) 
    1819 
    1920js.err.invalid= "%s" field is invalid 
  • trunk/lib/jelix/core-modules/jelix/locales/en_US/formserr.ISO-8859-1.properties

    r580 r702  
    11tag.missing=(800) %1$s is missing (file %2$s) 
    2 unknow.tag=(801) unknow tag %1$s  (file %2$s) 
     2unknow.tag=(801) unknown tag %1$s  (file %2$s) 
    33attribute.missing=(802) attribut %1$s is missing on %2$s (file %3$s) 
    44attribute.not.allowed=(803) attribut %1$s not allowed on %2$s (file %3$s) 
    5 datatype.unknow=(804) unknow datatype %1$s  on %2$s (file %3$s) 
     5datatype.unknow=(804) unknown datatype %1$s  on %2$s (file %3$s) 
    66invalid.xml.file=(805) invalid xml syntax in jforms file (file %s) 
    77selected.attribute.not.allowed=(806)"selected" attribute on <item> is not allowed when using defaultvalue attribute or <defaultvalues> (file %s) 
     
    1616invalid.upload.control.name = (815) The given control name "%s" is invalid or the corresponding control is not an upload (form=%s) 
    1717content.missing=(816) content of %1$s tag is missing (file %2$s) 
     18notunique.tag=(817) tag %1$s must be unique (file %2$s) 
    1819 
    1920js.err.invalid= "%s" field is invalid 
  • trunk/lib/jelix/core-modules/jelix/locales/en_US/formserr.ISO-8859-1.properties

    r580 r702  
    11tag.missing=(800) %1$s is missing (file %2$s) 
    2 unknow.tag=(801) unknow tag %1$s  (file %2$s) 
     2unknow.tag=(801) unknown tag %1$s  (file %2$s) 
    33attribute.missing=(802) attribut %1$s is missing on %2$s (file %3$s) 
    44attribute.not.allowed=(803) attribut %1$s not allowed on %2$s (file %3$s) 
    5 datatype.unknow=(804) unknow datatype %1$s  on %2$s (file %3$s) 
     5datatype.unknow=(804) unknown datatype %1$s  on %2$s (file %3$s) 
    66invalid.xml.file=(805) invalid xml syntax in jforms file (file %s) 
    77selected.attribute.not.allowed=(806)"selected" attribute on <item> is not allowed when using defaultvalue attribute or <defaultvalues> (file %s) 
     
    1616invalid.upload.control.name = (815) The given control name "%s" is invalid or the corresponding control is not an upload (form=%s) 
    1717content.missing=(816) content of %1$s tag is missing (file %2$s) 
     18notunique.tag=(817) tag %1$s must be unique (file %2$s) 
    1819 
    1920js.err.invalid= "%s" field is invalid 
  • trunk/lib/jelix/core-modules/jelix/locales/en_US/formserr.UTF-8.properties

    r580 r702  
    11tag.missing=(800) %1$s is missing (file %2$s) 
    2 unknow.tag=(801) unknow tag %1$s  (file %2$s) 
     2unknow.tag=(801) unknown tag %1$s  (file %2$s) 
    33attribute.missing=(802) attribut %1$s is missing on %2$s (file %3$s) 
    44attribute.not.allowed=(803) attribut %1$s not allowed on %2$s (file %3$s) 
    5 datatype.unknow=(804) unknow datatype %1$s  on %2$s (file %3$s) 
     5datatype.unknow=(804) unknown datatype %1$s  on %2$s (file %3$s) 
    66invalid.xml.file=(805) invalid xml syntax in jforms file (file %s) 
    77selected.attribute.not.allowed=(806)"selected" attribute on <item> is not allowed when using defaultvalue attribute or <defaultvalues> (file %s) 
     
    1616invalid.upload.control.name = (815) The given control name "%s" is invalid or the corresponding control is not an upload (form=%s) 
    1717content.missing=(816) content of %1$s tag is missing (file %2$s) 
     18notunique.tag=(817) tag %1$s must be unique (file %2$s) 
    1819 
    1920js.err.invalid= "%s" field is invalid 
  • trunk/lib/jelix/core-modules/jelix/locales/en_US/formserr.UTF-8.properties

    r580 r702  
    11tag.missing=(800) %1$s is missing (file %2$s) 
    2 unknow.tag=(801) unknow tag %1$s  (file %2$s) 
     2unknow.tag=(801) unknown tag %1$s  (file %2$s) 
    33attribute.missing=(802) attribut %1$s is missing on %2$s (file %3$s) 
    44attribute.not.allowed=(803) attribut %1$s not allowed on %2$s (file %3$s) 
    5 datatype.unknow=(804) unknow datatype %1$s  on %2$s (file %3$s) 
     5datatype.unknow=(804) unknown datatype %1$s  on %2$s (file %3$s) 
    66invalid.xml.file=(805) invalid xml syntax in jforms file (file %s) 
    77selected.attribute.not.allowed=(806)"selected" attribute on <item> is not allowed when using defaultvalue attribute or <defaultvalues> (file %s) 
     
    1616invalid.upload.control.name = (815) The given control name "%s" is invalid or the corresponding control is not an upload (form=%s) 
    1717content.missing=(816) content of %1$s tag is missing (file %2$s) 
     18notunique.tag=(817) tag %1$s must be unique (file %2$s) 
    1819 
    1920js.err.invalid= "%s" field is invalid 
  • trunk/lib/jelix/core-modules/jelix/locales/fr_FR/formserr.ISO-8859-1.properties

    r580 r702  
    1616invalid.upload.control.name = (815) Le nom de controle indiqu�%s" est invalide ou le control n'est pas un upload (form=%s) 
    1717content.missing=(816) le contenu de %1$s est manquant (fichier %2$s) 
     18notunique.tag=(817) La balise %1$s doit �e unique (fichier %2$s) 
    1819 
    1920js.err.invalid=La saisie de "%s" est invalide 
  • trunk/lib/jelix/core-modules/jelix/locales/fr_FR/formserr.ISO-8859-1.properties

    r580 r702  
    1616invalid.upload.control.name = (815) Le nom de controle indiqu�%s" est invalide ou le control n'est pas un upload (form=%s) 
    1717content.missing=(816) le contenu de %1$s est manquant (fichier %2$s) 
     18notunique.tag=(817) La balise %1$s doit �e unique (fichier %2$s) 
    1819 
    1920js.err.invalid=La saisie de "%s" est invalide 
  • trunk/lib/jelix/core-modules/jelix/locales/fr_FR/formserr.UTF-8.properties

    r580 r702  
    1616invalid.upload.control.name = (815) Le nom de controle indiqué "%s" est invalide ou le control n'est pas un upload (form=%s) 
    1717content.missing=(816) le contenu de %1$s est manquant (fichier %2$s) 
     18notunique.tag=(817) La balise %1$s doit être unique (fichier %2$s) 
    1819 
    1920js.err.invalid=La saisie de "%s" est invalide 
  • trunk/lib/jelix/core-modules/jelix/locales/fr_FR/formserr.UTF-8.properties

    r580 r702  
    1616invalid.upload.control.name = (815) Le nom de controle indiqué "%s" est invalide ou le control n'est pas un upload (form=%s) 
    1717content.missing=(816) le contenu de %1$s est manquant (fichier %2$s) 
     18notunique.tag=(817) La balise %1$s doit être unique (fichier %2$s) 
    1819 
    1920js.err.invalid=La saisie de "%s" est invalide 
  • trunk/lib/jelix/CREDITS

    r696 r702  
    9090 - added support of 'else' keyword for block plugin in jtpl (#349) 
    9191 - fixed bug in firebug support (#362) 
     92 - added support of <reset> in jforms (#258) 
    9293 
    9394Thibault Piront (aka nuks) 
  • trunk/lib/jelix/CREDITS

    r696 r702  
    9090 - added support of 'else' keyword for block plugin in jtpl (#349) 
    9191 - fixed bug in firebug support (#362) 
     92 - added support of <reset> in jforms (#258) 
    9293 
    9394Thibault Piront (aka nuks) 
  • trunk/lib/jelix/docs/ns/jforms.rng

    r700 r702  
    3434        </choice> 
    3535      </oneOrMore> 
     36      <optional> 
     37        <ref name="reset" /> 
     38      </optional> 
    3639  </define> 
    3740 
     
    320323--> 
    321324 
     325  <define name="reset"> 
     326     <element name="reset"> 
     327       <ref name="control.common" /> 
     328     </element> 
     329  </define> 
    322330   
    323331  <!-- 
  • trunk/lib/jelix/docs/ns/jforms.rng

    r700 r702  
    3434        </choice> 
    3535      </oneOrMore> 
     36      <optional> 
     37        <ref name="reset" /> 
     38      </optional> 
    3639  </define> 
    3740 
     
    320323--> 
    321324 
     325  <define name="reset"> 
     326     <element name="reset"> 
     327       <ref name="control.common" /> 
     328     </element> 
     329  </define> 
    322330   
    323331  <!-- 
  • trunk/lib/jelix/forms/jFormsBase.class.php

    r699 r702  
    44* @subpackage  forms 
    55* @author      Laurent Jouanneau 
    6 * @contributor 
    7 * @copyright   2006-2007 Laurent Jouanneau 
     6* @contributor Dominique Papin 
     7* @copyright   2006-2007 Laurent Jouanneau, 2007 Dominique Papin 
    88* @link        http://www.jelix.org 
    99* @licence     http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public Licence, see LICENCE file 
     
    4848     */ 
    4949    protected $_submits = array(); 
     50 
     51    /** 
     52     * Reset button 
     53     * @var jFormsControl 
     54     * @see jFormsControl 
     55     * @since 1.0 
     56     */ 
     57    protected $_reset = null; 
    5058 
    5159    /** 
     
    116124                } 
    117125            }elseif($ctrl->type=='submit' && $value) { 
    118                 // because IE send the <button> content as value instead of the content of the  
     126                // because IE send the <button> content as value instead of the content of the 
    119127                // "value" attribute, we should verify it and get the real value 
    120128                $datas = $ctrl->datasource->getDatas(); 
     
    189197                    }else { 
    190198                        $this->_container->datas[$name] = $ctrl->valueOnUncheck; 
    191                     }  
     199                    } 
    192200                }else{ 
    193201                    $this->_container->datas[$name] = $daorec->$name; 
     
    239247                // if no value and if the property is not required, we set null to it 
    240248                $daorec->$name = null; 
    241             }else if($daorec->$name == '' && $prop[$name]['defaultValue'] !== null  
     249            }else if($daorec->$name == '' && $prop[$name]['defaultValue'] !== null 
    242250                    && in_array($prop[$name]['datatype'], 
    243251                                array('int','integer','double','float'))) { 
     
    272280    /** 
    273281     * set datas from a DAO, in a control 
    274      *  
     282     * 
    275283     * The control must be a container like checkboxes or listbox with multiple attribute. 
    276284     * The form should contain a formId 
    277285     * 
    278286     * The Dao should map to an "association table" : its primary key should be composed by 
    279      * the primary key stored in the formId (or the given primarykey) + the field which will contain one of  
     287     * the primary key stored in the formId (or the given primarykey) + the field which will contain one of 
    280288     * the values of the control. If this order is not the same as defined into the dao, 
    281289     * you should provide the list of property names which corresponds to the primary key 
    282      * in this order : properties for the formId, followed by the property which contains  
     290     * in this order : properties for the formId, followed by the property which contains 
    283291     * the value. 
    284292     * @param string $controlName  the name of the control 
     
    332340     * The control must be a container like checkboxes or listbox with multiple attribute. 
    333341     * If the form contain a new record (no formId), you should call saveToDao before 
    334      * in order to get a new id (the primary key of the new record), or you should get a new id  
     342     * in order to get a new id (the primary key of the new record), or you should get a new id 
    335343     * by an other way. then you must pass this primary key in the third argument. 
    336344     * If the form have already a formId, then it will be used as a primary key, unless 
     
    338346     * 
    339347     * The Dao should map to an "association table" : its primary key should be 
    340      * the primary key stored in the formId + the field which will contain one of  
     348     * the primary key stored in the formId + the field which will contain one of 
    341349     * the values of the control. If this order is not the same as defined into the dao, 
    342350     * you should provide the list of property names which corresponds to the primary key 
    343      * in this order : properties for the formId, followed by the property which contains  
     351     * in this order : properties for the formId, followed by the property which contains 
    344352     * the value. 
    345353     * All existing records which have the formid in their keys are deleted 
     
    411419     * set an error message on a specific field 
    412420     * @param string $field the field name 
    413      * @param string $mesg  the error message string  
     421     * @param string $mesg  the error message string 
    414422     */ 
    415423    public function setErrorOn($field, $mesg){ 
     
    460468    /** 
    461469     * @param string $name the control name you want to get 
    462      * @return jFormsControl  
     470     * @return jFormsControl 
    463471     * @since jelix 1.0 
    464472     */ 
     
    469477     */ 
    470478    public function getSubmits(){ return $this->_submits; } 
     479  
     480    /** 
     481     * @return array of jFormsControl objects 
     482     */ 
     483    public function getReset(){ return $this->_reset; } 
    471484 
    472485    /** 
     
    498511 
    499512    /** 
    500      * save an uploaded file in the given directory. the given control must be  
     513     * save an uploaded file in the given directory. the given control must be 
    501514     * an upload control of course. 
    502515     * @param string $controlName the name of the upload control 
     
    568581        if($control->type =='submit') 
    569582            $this->_submits [$control->ref] = $control; 
    570         if($control->type =='upload'){ 
     583        else if($control->type =='reset') 
     584            $this->_reset = $control; 
     585        else if($control->type =='upload') 
    571586            $this->_uploads [$control->ref] = $control; 
    572         } 
     587 
    573588        if(!isset($this->_container->datas[$control->ref])){ 
    574589            if ( $control->datatype instanceof jDatatypeDateTime && $control->defaultValue == 'now') { 
  • trunk/lib/jelix/forms/jFormsBase.class.php

    r699 r702  
    44* @subpackage  forms 
    55* @author      Laurent Jouanneau 
    6 * @contributor 
    7 * @copyright   2006-2007 Laurent Jouanneau 
     6* @contributor Dominique Papin 
     7* @copyright   2006-2007 Laurent Jouanneau, 2007 Dominique Papin 
    88* @link        http://www.jelix.org 
    99* @licence     http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public Licence, see LICENCE file 
     
    4848     */ 
    4949    protected $_submits = array(); 
     50 
     51    /** 
     52     * Reset button 
     53     * @var jFormsControl 
     54     * @see jFormsControl 
     55     * @since 1.0 
     56     */ 
     57    protected $_reset = null; 
    5058 
    5159    /** 
     
    116124                } 
    117125            }elseif($ctrl->type=='submit' && $value) { 
    118                 // because IE send the <button> content as value instead of the content of the  
     126                // because IE send the <button> content as value instead of the content of the 
    119127                // "value" attribute, we should verify it and get the real value 
    120128                $datas = $ctrl->datasource->getDatas(); 
     
    189197                    }else { 
    190198                        $this->_container->datas[$name] = $ctrl->valueOnUncheck; 
    191                     }  
     199                    } 
    192200                }else{ 
    193201                    $this->_container->datas[$name] = $daorec->$name; 
     
    239247                // if no value and if the property is not required, we set null to it 
    240248                $daorec->$name = null; 
    241             }else if($daorec->$name == '' && $prop[$name]['defaultValue'] !== null  
     249            }else if($daorec->$name == '' && $prop[$name]['defaultValue'] !== null 
    242250                    && in_array($prop[$name]['datatype'], 
    243251                                array('int','integer','double','float'))) { 
     
    272280    /** 
    273281     * set datas from a DAO, in a control 
    274      *  
     282     * 
    275283     * The control must be a container like checkboxes or listbox with multiple attribute. 
    276284     * The form should contain a formId 
    277285     * 
    278286     * The Dao should map to an "association table" : its primary key should be composed by 
    279      * the primary key stored in the formId (or the given primarykey) + the field which will contain one of  
     287     * the primary key stored in the formId (or the given primarykey) + the field which will contain one of 
    280288     * the values of the control. If this order is not the same as defined into the dao, 
    281289     * you should provide the list of property names which corresponds to the primary key 
    282      * in this order : properties for the formId, followed by the property which contains  
     290     * in this order : properties for the formId, followed by the property which contains 
    283291     * the value. 
    284292     * @param string $controlName  the name of the control 
     
    332340     * The control must be a container like checkboxes or listbox with multiple attribute. 
    333341     * If the form contain a new record (no formId), you should call saveToDao before 
    334      * in order to get a new id (the primary key of the new record), or you should get a new id  
     342     * in order to get a new id (the primary key of the new record), or you should get a new id 
    335343     * by an other way. then you must pass this primary key in the third argument. 
    336344     * If the form have already a formId, then it will be used as a primary key, unless 
     
    338346     * 
    339347     * The Dao should map to an "association table" : its primary key should be 
    340      * the primary key stored in the formId + the field which will contain one of  
     348     * the primary key stored in the formId + the field which will contain one of 
    341349     * the values of the control. If this order is not the same as defined into the dao, 
    342350     * you should provide the list of property names which corresponds to the primary key 
    343      * in this order : properties for the formId, followed by the property which contains  
     351     * in this order : properties for the formId, followed by the property which contains 
    344352     * the value. 
    345353     * All existing records which have the formid in their keys are deleted 
     
    411419     * set an error message on a specific field 
    412420     * @param string $field the field name 
    413      * @param string $mesg  the error message string  
     421     * @param string $mesg  the error message string 
    414422     */ 
    415423    public function setErrorOn($field, $mesg){ 
     
    460468    /** 
    461469     * @param string $name the control name you want to get 
    462      * @return jFormsControl  
     470     * @return jFormsControl 
    463471     * @since jelix 1.0 
    464472     */ 
     
    469477     */ 
    470478    public function getSubmits(){ return $this->_submits; } 
     479  
     480    /** 
     481     * @return array of jFormsControl objects 
     482     */ 
     483    public function getReset(){ return $this->_reset; } 
    471484 
    472485    /** 
     
    498511 
    499512    /** 
    500      * save an uploaded file in the given directory. the given control must be  
     513     * save an uploaded file in the given directory. the given control must be 
    501514     * an upload control of course. 
    502515     * @param string $controlName the name of the upload control 
     
    568581        if($control->type =='submit') 
    569582            $this->_submits [$control->ref] = $control; 
    570         if($control->type =='upload'){ 
     583        else if($control->type =='reset') 
     584            $this->_reset = $control; 
     585        else if($control->type =='upload') 
    571586            $this->_uploads [$control->ref] = $control; 
    572         } 
     587 
    573588        if(!isset($this->_container->datas[$control->ref])){ 
    574589            if ( $control->datatype instanceof jDatatypeDateTime && $control->defaultValue == 'now') { 
  • trunk/lib/jelix/forms/jFormsBuilderBase.class.php

    r669 r702  
    44* @subpackage  forms 
    55* @author      Laurent Jouanneau 
    6 * @contributor Loic Mathaud 
    7 * @copyright   2006-2007 Laurent Jouanneau 
     6* @contributor Loic Mathaud, Dominique Papin 
     7* @copyright   2006-2007 Laurent Jouanneau, 2007 Dominique Papin 
    88* @copyright   2007 Loic Mathaud 
    99* @link        http://www.jelix.org 
     
    123123            echo '</div>'; 
    124124        } 
    125         echo '<script type="text/javascript">  
     125        echo '<script type="text/javascript"> 
    126126//<![CDATA[ 
    127127', $this->getJavascriptCheck($params[0],$params[1]),' 
     
    165165        if($ctrl->type == 'output' || $ctrl->type == 'checkboxes' || $ctrl->type == 'radiobuttons'){ 
    166166            echo '<span class="jforms-label',$required,$inError,'"',$hint,'>',htmlspecialchars($ctrl->label),'</span>'; 
    167         }else if($ctrl->type != 'submit'){ 
     167        }else if($ctrl->type != 'submit' && $ctrl->type != 'reset'){ 
    168168            $id = $this->_name.'_'.$ctrl->ref; 
    169169            echo '<label class="jforms-label',$required,$inError,'" for="'.$id.'"',$hint,'>'.htmlspecialchars($ctrl->label).'</label>'; 
     
    204204                foreach($ctrl->datasource->getDatas() as $v=>$label){ 
    205205                    echo '<input type="checkbox"',$attrs,$i,'" value="',htmlspecialchars($v),'"'; 
    206                     if(in_array($v,$value))  
     206                    if(in_array($v,$value)) 
    207207                        echo ' checked="checked"'; 
    208208                    echo $readonly,$class,$this->_endt,'<label for="',$id,$i,'">',htmlspecialchars($label),'</label>'; 
     
    212212                foreach($ctrl->datasource->getDatas() as $v=>$label){ 
    213213                    echo '<input type="checkbox"',$attrs,$i,'" value="',htmlspecialchars($v),'"'; 
    214                     if($v == $value)  
     214                    if($v == $value) 
    215215                        echo ' checked="checked"'; 
    216216                    echo $readonly,$class,$this->_endt,'<label for="',$id,$i,'">',htmlspecialchars($label),'</label>'; 
     
    318318            } 
    319319            break; 
     320        case 'reset': 
     321            echo '<button type="reset"',$id,$hint,'>',htmlspecialchars($ctrl->label),'</button>'; 
     322            break; 
    320323        } 
    321324 
  • trunk/lib/jelix/forms/jFormsBuilderBase.class.php

    r669 r702  
    44* @subpackage  forms 
    55* @author      Laurent Jouanneau 
    6 * @contributor Loic Mathaud 
    7 * @copyright   2006-2007 Laurent Jouanneau 
     6* @contributor Loic Mathaud, Dominique Papin 
     7* @copyright   2006-2007 Laurent Jouanneau, 2007 Dominique Papin 
    88* @copyright   2007 Loic Mathaud 
    99* @link        http://www.jelix.org 
     
    123123            echo '</div>'; 
    124124        } 
    125         echo '<script type="text/javascript">  
     125        echo '<script type="text/javascript"> 
    126126//<![CDATA[ 
    127127', $this->getJavascriptCheck($params[0],$params[1]),' 
     
    165165        if($ctrl->type == 'output' || $ctrl->type == 'checkboxes' || $ctrl->type == 'radiobuttons'){ 
    166166            echo '<span class="jforms-label',$required,$inError,'"',$hint,'>',htmlspecialchars($ctrl->label),'</span>'; 
    167         }else if($ctrl->type != 'submit'){ 
     167        }else if($ctrl->type != 'submit' && $ctrl->type != 'reset'){ 
    168168            $id = $this->_name.'_'.$ctrl->ref; 
    169169            echo '<label class="jforms-label',$required,$inError,'" for="'.$id.'"',$hint,'>'.htmlspecialchars($ctrl->label).'</label>'; 
     
    204204                foreach($ctrl->datasource->getDatas() as $v=>$label){ 
    205205                    echo '<input type="checkbox"',$attrs,$i,'" value="',htmlspecialchars($v),'"'; 
    206                     if(in_array($v,$value))  
     206                    if(in_array($v,$value)) 
    207207                        echo ' checked="checked"'; 
    208208                    echo $readonly,$class,$this->_endt,'<label for="',$id,$i,'">',htmlspecialchars($label),'</label>'; 
     
    212212                foreach($ctrl->datasource->getDatas() as $v=>$label){ 
    213213                    echo '<input type="checkbox"',$attrs,$i,'" value="',htmlspecialchars($v),'"'; 
    214                     if($v == $value)  
     214                    if($v == $value) 
    215215                        echo ' checked="checked"'; 
    216216                    echo $readonly,$class,$this->_endt,'<label for="',$id,$i,'">',htmlspecialchars($label),'</label>'; 
     
    318318            } 
    319319            break; 
     320        case 'reset': 
     321            echo '<button type="reset"',$id,$hint,'>',htmlspecialchars($ctrl->label),'</button>'; 
     322            break; 
    320323        } 
    321324 
  • trunk/lib/jelix/forms/jFormsCompiler.class.php

    r699 r702  
    44* @subpackage forms 
    55* @author     Laurent Jouanneau 
    6 * @contributor Loic Mathaud 
     6* @contributor Loic Mathaud, Dominique Papin 
    77* @contributor Uriel Corfa Emotic SARL 
    88* @copyright   2006-2007 Laurent Jouanneau 
    9 * @copyright   2007 Loic Mathaud 
     9* @copyright   2007 Loic Mathaud, 2007 Dominique Papin 
    1010* @copyright   2007 Emotic SARL 
    1111* @link        http://www.jelix.org 
     
    3737            throw new jException('jelix~formserr.invalid.xml.file',array($this->sourceFile)); 
    3838        } 
    39  
    40         if($doc->documentElement->namespaceURI != JELIX_NAMESPACE_BASE.'forms/1.0'){ 
    41             throw new jException('jelix~formserr.namespace.wrong',array($this->sourceFile)); 
    42         } 
    43  
    44         $xml = simplexml_import_dom($doc); 
    4539 
    4640        $source=array(); 
     
    6458        $srcjs[]='$js.="jForms.tForm.setHelpDecorator(new ".$helpDecoratorName."());\n";'; 
    6559 
    66         foreach($xml->children() as $controltype=>$control){ 
    67             $source[] = $this->generatePHPControl($controltype, $control); 
    68             $srcjs[] =  $this->generateJsControl($controltype, $control); 
    69         } 
     60        $this->generatePHPContent($doc, $source, $srcjs); 
     61 
    7062        $source[]="  }\n} ?>"; 
    7163 
     
    8274    } 
    8375 
     76    protected function generatePHPContent($doc, &$source, &$srcjs){ 
     77 
     78        if($doc->documentElement->namespaceURI != JELIX_NAMESPACE_BASE.'forms/1.0'){ 
     79           throw new jException('jelix~formserr.namespace.wrong',array($this->sourceFile)); 
     80        } 
     81 
     82        $xml = simplexml_import_dom($doc); 
     83 
     84        if (count($xml->reset) > 1 ) 
     85            throw new jException('jelix~formserr.notunique.tag',array('reset',$this->sourceFile)); 
     86 
     87 
     88        foreach($xml->children() as $controltype=>$control){ 
     89            $source[] = $this->generatePHPControl($controltype, $control); 
     90            $srcjs[] =  $this->generateJsControl($controltype, $control); 
     91        } 
     92    } 
    8493 
    8594    protected function generatePHPControl($controltype, $control){ 
     
    106115            $dt = (string)$control['type']; 
    107116            if(!in_array(strtolower($dt), array('string','boolean','decimal','integer','hexadecimal', 
    108                                                 'datetime','date','time','localedatetime','localedate','localetime',  
     117                                                'datetime','date','time','localedatetime','localedate','localetime', 
    109118                                                'url','email','ipv4','ipv6'))){ 
    110119               throw new jException('jelix~formserr.datatype.unknow',array($dt,$controltype,$this->sourceFile)); 
     
    118127        // readonly support 
    119128        if(isset($control['readonly'])){ 
    120             if($controltype == 'output' || $controltype == 'submit'){ 
     129            if($controltype == 'output' || $controltype == 'submit' || $controltype == 'reset'){ 
    121130                throw new jException('jelix~formserr.attribute.not.allowed',array('readonly',$controltype,$this->sourceFile)); 
    122131            } 
     
    126135        // required support 
    127136        if(isset($control['required'])){ 
    128             if($controltype == 'checkbox' || $controltype == 'output' || $controltype == 'submit'){ 
     137            if($controltype == 'checkbox' || $controltype == 'output' || $controltype == 'submit' || $controltype == 'reset'){ 
    129138                throw new jException('jelix~formserr.attribute.not.allowed',array('required',$controltype,$this->sourceFile)); 
    130139            }