Changeset 526

Show
Ignore:
Timestamp:
08/08/07 15:52:45 (1 year ago)
Author:
laurentj
Message:

ticket #186: jforms, required field are indicated
ticket #181: jforms, errors are displayed in the form
many bug fixes in jforms compiler, checker, javascript etc.. added some additionnal unit tests.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/build/manifests/testapp.mn

    r512 r526  
    114114  jdb.2_queries_with_pdo.html.php 
    115115  jforms.html.php 
     116  jforms.check_datas.html.php 
    116117  jforms.compiler.html.php 
    117118  jforms.htmlbuilder.html.php 
     
    119120  jtpl.compiler.html_cli.php 
    120121  jtpl.expressions_parsing.html_cli.php 
     122  utils.jdatatype.html_cli.php 
    121123  utils.jfilter.html_cli.php 
    122124 
  • trunk/build/manifests/testapp.mn

    r512 r526  
    114114  jdb.2_queries_with_pdo.html.php 
    115115  jforms.html.php 
     116  jforms.check_datas.html.php 
    116117  jforms.compiler.html.php 
    117118  jforms.htmlbuilder.html.php 
     
    119120  jtpl.compiler.html_cli.php 
    120121  jtpl.expressions_parsing.html_cli.php 
     122  utils.jdatatype.html_cli.php 
    121123  utils.jfilter.html_cli.php 
    122124 
  • trunk/lib/jelix-www/design/jform.css

    r525 r526  
    99 
    1010.jforms-required { font-weight:bold; } 
    11 .jforms-required:after { content:"*"; font-weight:bold; } 
    12 .jforms-required-star {font-weight:bold; } 
     11.jforms-required:after { content:"*"; font-weight:bold; color:red; } 
    1312 
     13.jforms-error-list { color:red; border:1px solid red;} 
     14 
     15input.jforms-error, textarea.jforms-error, select.jforms-error {background-color: #ffd6d7;} 
     16 
     17label.jforms-error, span.jforms-error {font-style:italic; color:red;} 
  • trunk/lib/jelix-www/design/jform.css

    r525 r526  
    99 
    1010.jforms-required { font-weight:bold; } 
    11 .jforms-required:after { content:"*"; font-weight:bold; } 
    12 .jforms-required-star {font-weight:bold; } 
     11.jforms-required:after { content:"*"; font-weight:bold; color:red; } 
    1312 
     13.jforms-error-list { color:red; border:1px solid red;} 
     14 
     15input.jforms-error, textarea.jforms-error, select.jforms-error {background-color: #ffd6d7;} 
     16 
     17label.jforms-error, span.jforms-error {font-style:italic; color:red;} 
  • trunk/lib/jelix-www/js/jforms.js

    r522 r526  
    166166    _getValue : function (elt){ 
    167167        var value=''; 
    168         switch (elt.localName.toLowerCase()) { 
    169             case "input": 
    170                 switch (elt.getAttribute("type")) { 
    171                 case "checkbox": 
    172                 case "radio": 
    173                     if (elt.checked) 
    174                         value = 'true'; 
    175                     else 
    176                         value = 'false'; 
     168        if(elt.nodeType) { // this is a node 
     169            switch (elt.localName.toLowerCase()) { 
     170                case "input": 
     171                    switch (elt.getAttribute("type")) { 
     172                    case "checkbox": 
     173                    case "radio": 
     174                        if (elt.checked) 
     175                            value = 'true'; 
     176                        else 
     177                            value = 'false'; 
     178                        break; 
     179                    default: 
     180                        value = elt.value; 
     181                        break; 
     182                    } 
    177183                    break; 
    178                 default
    179                     value = elt.value; 
     184                case "textarea"
     185                    value= elt.value; 
    180186                    break; 
     187                case "select": 
     188                    if (!elt.multiple) { 
     189                        value =  elt.value; 
     190                        break; 
     191                    } 
     192                    var options = elt.getElementsByTagName("option"); 
     193                    value = []; 
     194                    for (var i = 0; i < options.length; i++) { 
     195                        if (options[i].selected) { 
     196                            value.push(options[i].value); 
     197                        } 
     198                    } 
     199                    break; 
     200            } 
     201        } else if(elt.item){ 
     202            // this is a NodeList of radio buttons 
     203            value = [] 
     204            for (var i = 0; i < elt.length; i++) { 
     205                var radio = elt.item(i); 
     206                if (radio.checked) { 
     207                    value.push(radio.value); 
    181208                } 
    182                 break; 
    183             case "textarea": 
    184                 value= elt.value; 
    185                 break; 
    186             case "select": 
    187                 if (!elt.multiple) { 
    188                     value =  elt.value; 
    189                     break; 
    190                 } 
    191                 var options = elt.getElementsByTagName("option"); 
    192                 value = []; 
    193                 for (i = 0; i < options.length; i++) { 
    194                     if (options[i].selected) { 
    195                         value.push(options[i].value); 
    196                     } 
    197                 } 
    198                 break; 
     209            } 
    199210        } 
    200211        return value; 
    201212    }, 
    202213 
    203     showHelp : function(aForm, aControl){ 
    204         var frm = this._forms[aForm.name]; 
     214    showHelp : function(aFormName, aControlName){ 
     215        var frm = this._forms[aFormName]; 
    205216        var ctrls = frm.controls; 
    206217        var ctrl = null; 
    207218        for(var i=0; i < ctrls.length; i++){ 
    208             if (ctrls[i].name == aControl) { 
     219            if (ctrls[i].name == aControlName) { 
    209220                ctrl = ctrls[i]; 
    210221                break; 
     
    272283    addError : function(control, messageType){ 
    273284        if(messageType == 1){ 
    274             this.message  += control.errRequired + "\n"; 
     285            this.message  +="* "+control.errRequired + "\n"; 
    275286        }else if(messageType == 2){ 
    276             this.message  += control.errInvalid + "\n"; 
     287            this.message  +="* "+control.errInvalid + "\n"; 
    277288        }else{ 
    278             this.message  += "Error on '"+control.label+"' field\n"; 
     289            this.message  += "* Error on '"+control.label+"' field\n"; 
    279290        } 
    280291    }, 
  • trunk/lib/jelix-www/js/jforms.js

    r522 r526  
    166166    _getValue : function (elt){ 
    167167        var value=''; 
    168         switch (elt.localName.toLowerCase()) { 
    169             case "input": 
    170                 switch (elt.getAttribute("type")) { 
    171                 case "checkbox": 
    172                 case "radio": 
    173                     if (elt.checked) 
    174                         value = 'true'; 
    175                     else 
    176                         value = 'false'; 
     168        if(elt.nodeType) { // this is a node 
     169            switch (elt.localName.toLowerCase()) { 
     170                case "input": 
     171                    switch (elt.getAttribute("type")) { 
     172                    case "checkbox": 
     173                    case "radio": 
     174                        if (elt.checked) 
     175                            value = 'true'; 
     176                        else 
     177                            value = 'false'; 
     178                        break; 
     179                    default: 
     180                        value = elt.value; 
     181                        break; 
     182                    } 
    177183                    break; 
    178                 default
    179                     value = elt.value; 
     184                case "textarea"
     185                    value= elt.value; 
    180186                    break; 
     187                case "select": 
     188                    if (!elt.multiple) { 
     189                        value =  elt.value; 
     190                        break; 
     191                    } 
     192                    var options = elt.getElementsByTagName("option"); 
     193                    value = []; 
     194                    for (var i = 0; i < options.length; i++) { 
     195                        if (options[i].selected) { 
     196                            value.push(options[i].value); 
     197                        } 
     198                    } 
     199                    break; 
     200            } 
     201        } else if(elt.item){ 
     202            // this is a NodeList of radio buttons 
     203            value = [] 
     204            for (var i = 0; i < elt.length; i++) { 
     205                var radio = elt.item(i); 
     206                if (radio.checked) { 
     207                    value.push(radio.value); 
    181208                } 
    182                 break; 
    183             case "textarea": 
    184                 value= elt.value; 
    185                 break; 
    186             case "select": 
    187                 if (!elt.multiple) { 
    188                     value =  elt.value; 
    189                     break; 
    190                 } 
    191                 var options = elt.getElementsByTagName("option"); 
    192                 value = []; 
    193                 for (i = 0; i < options.length; i++) { 
    194                     if (options[i].selected) { 
    195                         value.push(options[i].value); 
    196                     } 
    197                 } 
    198                 break; 
     209            } 
    199210        } 
    200211        return value; 
    201212    }, 
    202213 
    203     showHelp : function(aForm, aControl){ 
    204         var frm = this._forms[aForm.name]; 
     214    showHelp : function(aFormName, aControlName){ 
     215        var frm = this._forms[aFormName]; 
    205216        var ctrls = frm.controls; 
    206217        var ctrl = null; 
    207218        for(var i=0; i < ctrls.length; i++){ 
    208             if (ctrls[i].name == aControl) { 
     219            if (ctrls[i].name == aControlName) { 
    209220                ctrl = ctrls[i]; 
    210221                break; 
     
    272283    addError : function(control, messageType){ 
    273284        if(messageType == 1){ 
    274             this.message  += control.errRequired + "\n"; 
     285            this.message  +="* "+control.errRequired + "\n"; 
    275286        }else if(messageType == 2){ 
    276             this.message  += control.errInvalid + "\n"; 
     287            this.message  +="* "+control.errInvalid + "\n"; 
    277288        }else{ 
    278             this.message  += "Error on '"+control.label+"' field\n"; 
     289            this.message  += "* Error on '"+control.label+"' field\n"; 
    279290        } 
    280291    }, 
  • trunk/lib/jelix/docs/ns/jforms-controls.rng

    r523 r526  
    1212        <ref name="hint" /> 
    1313     </optional> 
    14      <!-- 
    1514     <optional> 
    1615        <ref name="alert" /> 
    1716     </optional> 
    18      <optional> 
    19         <ref name="help" /> 
    20      </optional>--> 
    2117  </define> 
    2218  <!-- 
     
    324320  </define> 
    325321   
    326 <!-- 
    327322  <define name="alert"> 
    328323     <element name="alert"> 
     324        <optional> 
     325           <attribute name="type"> 
     326                <choice> 
     327                    <value>required</value> 
     328                    <value>invalid</value> 
     329                </choice> 
     330            </attribute> 
     331        </optional> 
    329332        <ref name="message.content" /> 
    330333     </element> 
    331334  </define> 
    332 --> 
    333335</grammar> 
  • trunk/lib/jelix/docs/ns/jforms-controls.rng

    r523 r526  
    1212        <ref name="hint" /> 
    1313     </optional> 
    14      <!-- 
    1514     <optional> 
    1615        <ref name="alert" /> 
    1716     </optional> 
    18      <optional> 
    19         <ref name="help" /> 
    20      </optional>--> 
    2117  </define> 
    2218  <!-- 
     
    324320  </define> 
    325321   
    326 <!-- 
    327322  <define name="alert"> 
    328323     <element name="alert"> 
     324        <optional> 
     325           <attribute name="type"> 
     326                <choice> 
     327                    <value>required</value> 
     328                    <value>invalid</value> 
     329                </choice> 
     330            </attribute> 
     331        </optional> 
    329332        <ref name="message.content" /> 
    330333     </element> 
    331334  </define> 
    332 --> 
    333335</grammar> 
  • trunk/lib/jelix/forms/jFormsBase.class.php

    r504 r526  
    9494        foreach($this->_controls as $name=>$ctrl){ 
    9595            $value=$this->_container->datas[$name]; 
    96             if($value === null && $ctrl->required){ 
    97                 $this->_container->errors[$name]=JFORM_ERRDATA_REQUIRED; 
    98             }else{ 
    99                 if(is_array($value))
     96            if(is_array($value)){ 
     97                if(count($value) == 0 && $ctrl->required){ 
     98                    $this->_container->errors[$name]=JFORM_ERRDATA_REQUIRED; 
     99                }else
    100100                    foreach($value as $v){ 
    101101                        if(!$ctrl->datatype->check($v)){ 
     
    104104                        } 
    105105                    } 
    106                 }elseif(!$ctrl->datatype->check($value)){ 
    107                     $this->_container->errors[$name]=JFORM_ERRDATA_INVALID; 
     106                } 
     107            }else{ 
     108                if($value == '' && $ctrl->required){ 
     109                    $this->_container->errors[$name]=JFORM_ERRDATA_REQUIRED; 
     110                }else{ 
     111                    if($ctrl->type == 'checkbox' && $value ==''){ 
     112                        $value='false'; 
     113                    } 
     114                    if(!$ctrl->datatype->check($value)){ 
     115                        $this->_container->errors[$name]=JFORM_ERRDATA_INVALID; 
     116                    } 
    108117                } 
    109118            } 
  • trunk/lib/jelix/forms/jFormsBase.class.php

    r504 r526  
    9494        foreach($this->_controls as $name=>$ctrl){ 
    9595            $value=$this->_container->datas[$name]; 
    96             if($value === null && $ctrl->required){ 
    97                 $this->_container->errors[$name]=JFORM_ERRDATA_REQUIRED; 
    98             }else{ 
    99                 if(is_array($value))
     96            if(is_array($value)){ 
     97                if(count($value) == 0 && $ctrl->required){ 
     98                    $this->_container->errors[$name]=JFORM_ERRDATA_REQUIRED; 
     99                }else
    100100                    foreach($value as $v){ 
    101101                        if(!$ctrl->datatype->check($v)){ 
     
    104104                        } 
    105105                    } 
    106                 }elseif(!$ctrl->datatype->check($value)){ 
    107                     $this->_container->errors[$name]=JFORM_ERRDATA_INVALID; 
     106                } 
     107            }else{ 
     108                if($value == '' && $ctrl->required){ 
     109                    $this->_container->errors[$name]=JFORM_ERRDATA_REQUIRED; 
     110                }else{ 
     111                    if($ctrl->type == 'checkbox' && $value ==''){ 
     112                        $value='false'; 
     113                    } 
     114                    if(!$ctrl->datatype->check($value)){ 
     115                        $this->_container->errors[$name]=JFORM_ERRDATA_INVALID; 
     116                    } 
    108117                } 
    109118            } 
  • trunk/lib/jelix/forms/jFormsBuilderBase.class.php

    r525 r526  
    9595//]]> 
    9696</script>'; 
     97        $errors = $this->_form->getContainer()->errors; 
     98        if(count($errors)){ 
     99            $ctrls = $this->_form->getControls(); 
     100            echo '<ul class="jforms-error-list">'; 
     101            $errRequired=''; 
     102            foreach($errors as $cname => $err){ 
     103                if($err == JFORM_ERRDATA_REQUIRED) { 
     104                    if($ctrls[$cname]->alertRequired){ 
     105                        echo '<li>', $ctrls[$cname]->alertRequired,'</li>'; 
     106                    }else{ 
     107                        echo '<li>', jLocale::get('jelix~formserr.js.err.required', $ctrls[$cname]->label),'</li>'; 
     108                    } 
     109                }else{ 
     110                    if($ctrls[$cname]->alertRequired){ 
     111                        echo '<li>', $ctrls[$cname]->alertInvalid,'</li>'; 
     112                    }else{ 
     113                        echo '<li>', jLocale::get('jelix~formserr.js.err.invalid', $ctrls[$cname]->label),'</li>'; 
     114                    } 
     115                } 
     116 
     117            } 
     118            echo '</ul>'; 
     119        } 
    97120    } 
    98121 
     
    103126    public function outputControlLabel($ctrl){ 
    104127        $required = ($ctrl->required == ''?'':' jforms-required'); 
     128        $inError = (isset($this->_form->getContainer()->errors[$ctrl->ref]) ?' jforms-error':''); 
     129        $hint = ($ctrl->hint == ''?'':' title="'.htmlspecialchars($ctrl->hint).'"'); 
    105130        if($ctrl->type == 'output' || $ctrl->type == 'checkboxes' || $ctrl->type == 'radiobuttons'){ 
    106             $hint = ($ctrl->hint == ''?'':' title="'.htmlspecialchars($ctrl->hint).'"'); 
    107             echo '<span class="jforms-label',$required,'"',$hint,'>',htmlspecialchars($ctrl->label),'</span>'; 
     131            echo '<span class="jforms-label',$required,$inError,'"',$hint,'>',htmlspecialchars($ctrl->label),'</span>'; 
    108132        }else if($ctrl->type != 'submit'){ 
    109133            $id = $this->_name.'_'.$ctrl->ref; 
    110             echo '<label class="jforms-label',$required,'" for="'.$id.'">'.htmlspecialchars($ctrl->label).'</label>'; 
     134            echo '<label class="jforms-label',$required,$inError,'" for="'.$id.'"',$hint,'>'.htmlspecialchars($ctrl->label).'</label>'; 
    111135        } 
    112136    } 
     
    116140        $readonly = ($ctrl->readonly?' readonly="readonly"':''); 
    117141        $hint = ($ctrl->hint == ''?'':' title="'.htmlspecialchars($ctrl->hint).'"'); 
    118  
     142        $class = (isset($this->_form->getContainer()->errors[$ctrl->ref]) ?' class="jforms-error"':''); 
    119143        switch($ctrl->type){ 
    120144        case 'input': 
     
    122146            if($value === null) 
    123147                $value = $ctrl->defaultValue; 
    124             echo '<input type="text"',$id,$readonly,$hint,' value="',htmlspecialchars($value),'"/>'; 
     148            echo '<input type="text"',$id,$readonly,$hint,$class,' value="',htmlspecialchars($value),'"/>'; 
    125149            break; 
    126150        case 'checkbox': 
     
    133157                $v=""; 
    134158            } 
    135             echo '<input type="checkbox"',$id,$readonly,$hint,$v,' value="true"/>'; 
     159            echo '<input type="checkbox"',$id,$readonly,$hint,$class,$v,' value="true"/>'; 
    136160            break; 
    137161        case 'checkboxes': 
     
    152176                    if(in_array($v,$value))  
    153177                        echo ' checked="checked"'; 
    154                     echo $readonly,'/><label for="',$id,$i,'">',htmlspecialchars($label),'</label>'; 
     178                    echo $readonly,$class,'/><label for="',$id,$i,'">',htmlspecialchars($label),'</label>'; 
    155179                    $i++; 
    156180                } 
     
    160184                    if($v == $value)  
    161185                        echo ' checked="checked"'; 
    162                     echo $readonly,'/><label for="',$id,$i,'">',htmlspecialchars($label),'</label>'; 
     186                    echo $readonly,$class,'/><label for="',$id,$i,'">',htmlspecialchars($label),'</label>'; 
    163187                    $i++; 
    164188                } 
     
    174198            } 
    175199            foreach($ctrl->datasource->getDatas() as $v=>$label){ 
    176                 echo '<input type="radio"',$id,$i,'" value="',htmlspecialchars($v),'"',($v==$value?' checked="checked"':''),$readonly,'/>'; 
     200                echo '<input type="radio"',$id,$i,'" value="',htmlspecialchars($v),'"',($v==$value?' checked="checked"':''),$readonly,$class,'/>'; 
    177201                echo '<label for="',$this->_name,'_',$ctrl->ref,'_',$i,'">',htmlspecialchars($label),'</label>'; 
    178202                $i++; 
     
    180204            break; 
    181205        case 'menulist': 
    182             echo '<select',$id,$readonly,$hint,' size="1">'; 
     206            echo '<select',$id,$readonly,$hint,$class,' size="1">'; 
    183207            $value = $this->_form->getData($ctrl->ref); 
    184208            if($value === null){ 
     
    193217        case 'listbox': 
    194218            if($ctrl->multiple){ 
    195                 echo '<select name="',$ctrl->ref,'[]" id="',$this->_name,'_',$ctrl->ref,'"',$readonly,$hint,' size="',$ctrl->size,'" multiple="multiple">'; 
     219                echo '<select name="',$ctrl->ref,'[]" id="',$this->_name,'_',$ctrl->ref,'"',$readonly,$hint,$class,' size="',$ctrl->size,'" multiple="multiple">'; 
    196220                $value = $this->_form->getData($ctrl->ref); 
    197221                if($value == null){ 
     
    225249                } 
    226250 
    227                 echo '<select',$id,$readonly,$hint,' size="',$ctrl->size,'">'; 
     251                echo '<select',$id,$readonly,$hint,$class,' size="',$ctrl->size,'">'; 
    228252                foreach($ctrl->datasource->getDatas() as $v=>$label){ 
    229253                    echo '<option value="',htmlspecialchars($v),'"',($v==$value?' selected="selected"':''),'>',htmlspecialchars($label),'</option>'; 
     
    236260            if($value === null) 
    237261                $value = $ctrl->defaultValue; 
    238             echo '<textarea',$id,$readonly,$hint,'>',htmlspecialchars($value),'</textarea>'; 
     262            echo '<textarea',$id,$readonly,$hint,$class,'>',htmlspecialchars($value),'</textarea>'; 
    239263            break; 
    240264        case 'secret': 
    241             echo '<input type="password"',$id,$readonly,$hint,' value="',htmlspecialchars($this->_form->getData($ctrl->ref)),'"/>'; 
     265            echo '<input type="password"',$id,$readonly,$hint,$class,' value="',htmlspecialchars($this->_form->getData($ctrl->ref)),'"/>'; 
    242266            break; 
    243267        case 'output': 
     
    249273            break; 
    250274        case 'upload': 
    251             echo '<input type="file"',$id,$readonly,$hint,' value=""/>'; // ',htmlspecialchars($this->_form->getData($ctrl->ref)),' 
     275            echo '<input type="file"',$id,$readonly,$hint,$class,' value=""/>'; // ',htmlspecialchars($this->_form->getData($ctrl->ref)),' 
    252276            break; 
    253277        case 'submit': 
  • trunk/lib/jelix/forms/jFormsBuilderBase.class.php

    r525 r526  
    9595//]]> 
    9696</script>'; 
     97        $errors = $this->_form->getContainer()->errors; 
     98        if(count($errors)){ 
     99            $ctrls = $this->_form->getControls(); 
     100            echo '<ul class="jforms-error-list">'; 
     101            $errRequired=''; 
     102            foreach($errors as $cname => $err){ 
     103                if($err == JFORM_ERRDATA_REQUIRED) { 
     104                    if($ctrls[$cname]->alertRequired){ 
     105                        echo '<li>', $ctrls[$cname]->alertRequired,'</li>'; 
     106                    }else{ 
     107                        echo '<li>', jLocale::get('jelix~formserr.js.err.required', $ctrls[$cname]->label),'</li>'; 
     108                    } 
     109                }else{ 
     110                    if($ctrls[$cname]->alertRequired){ 
     111                        echo '<li>', $ctrls[$cname]->alertInvalid,'</li>'; 
     112                    }else{ 
     113                        echo '<li>', jLocale::get('jelix~formserr.js.err.invalid', $ctrls[$cname]->label),'</li>'; 
     114                    } 
     115                } 
     116 
     117            } 
     118            echo '</ul>'; 
     119        } 
    97120    } 
    98121 
     
    103126    public function outputControlLabel($ctrl){ 
    104127        $required = ($ctrl->required == ''?'':' jforms-required'); 
     128        $inError = (isset($this->_form->getContainer()->errors[$ctrl->ref]) ?' jforms-error':''); 
     129        $hint = ($ctrl->hint == ''?'':' title="'.htmlspecialchars($ctrl->hint).'"'); 
    105130        if($ctrl->type == 'output' || $ctrl->type == 'checkboxes' || $ctrl->type == 'radiobuttons'){ 
    106             $hint = ($ctrl->hint == ''?'':' title="'.htmlspecialchars($ctrl->hint).'"'); 
    107             echo '<span class="jforms-label',$required,'"',$hint,'>',htmlspecialchars($ctrl->label),'</span>'; 
     131            echo '<span class="jforms-label',$required,$inError,'"',$hint,'>',htmlspecialchars($ctrl->label),'</span>'; 
    108132        }else if($ctrl->type != 'submit'){ 
    109133            $id = $this->_name.'_'.$ctrl->ref; 
    110             echo '<label class="jforms-label',$required,'" for="'.$id.'">'.htmlspecialchars($ctrl->label).'</label>'; 
     134            echo '<label class="jforms-label',$required,$inError,'" for="'.$id.'"',$hint,'>'.htmlspecialchars($ctrl->label).'</label>'; 
    111135        } 
    112136    } 
     
    116140        $readonly = ($ctrl->readonly?' readonly="readonly"':''); 
    117141        $hint = ($ctrl->hint == ''?'':' title="'.htmlspecialchars($ctrl->hint).'"'); 
    118  
     142        $class = (isset($this->_form->getContainer()->errors[$ctrl->ref]) ?' class="jforms-error"':''); 
    119143        switch($ctrl->type){ 
    120144        case 'input': 
     
    122146            if($value === null) 
    123147                $value = $ctrl->defaultValue; 
    124             echo '<input type="text"',$id,$readonly,$hint,' value="',htmlspecialchars($value),'"/>'; 
     148            echo '<input type="text"',$id,$readonly,$hint,$class,' value="',htmlspecialchars($value),'"/>'; 
    125149            break; 
    126150        case 'checkbox': 
     
    133157                $v=""; 
    134158            } 
    135             echo '<input type="checkbox"',$id,$readonly,$hint,$v,' value="true"/>'; 
     159            echo '<input type="checkbox"',$id,$readonly,$hint,$class,$v,' value="true"/>'; 
    136160            break; 
    137161        case 'checkboxes': 
     
    152176                    if(in_array($v,$value))  
    153177                        echo ' checked="checked"'; 
    154                     echo $readonly,'/><label for="',$id,$i,'">',htmlspecialchars($label),'</label>'; 
     178                    echo $readonly,$class,'/><label for="',$id,$i,'">',htmlspecialchars($label),'</label>'; 
    155179                    $i++; 
    156180                } 
     
    160184                    if($v == $value)  
    161185                        echo ' checked="checked"'; 
    162                     echo $readonly,'/><label for="',$id,$i,'">',htmlspecialchars($label),'</label>'; 
     186                    echo $readonly,$class,'/><label for="',$id,$i,'">',htmlspecialchars($label),'</label>'; 
    163187                    $i++; 
    164188                } 
     
    174198            } 
    175199            foreach($ctrl->datasource->getDatas() as $v=>$label){ 
    176                 echo '<input type="radio"',$id,$i,'" value="',htmlspecialchars($v),'"',($v==$value?' checked="checked"':''),$readonly,'/>'; 
     200                echo '<input type="radio"',$id,$i,'" value="',htmlspecialchars($v),'"',($v==$value?' checked="checked"':''),$readonly,$class,'/>'; 
    177201                echo '<label for="',$this->_name,'_',$ctrl->ref,'_',$i,'">',htmlspecialchars($label),'</label>'; 
    178202                $i++; 
     
    180204            break; 
    181205        case 'menulist': 
    182             echo '<select',$id,$readonly,$hint,' size="1">'; 
     206            echo '<select',$id,$readonly,$hint,$class,' size="1">'; 
    183207            $value = $this->_form->getData($ctrl->ref); 
    184208            if($value === null){ 
     
    193217        case 'listbox': 
    194218            if($ctrl->multiple){ 
    195                 echo '<select name="',$ctrl->ref,'[]" id="',$this->_name,'_',$ctrl->ref,'"',$readonly,$hint,' size="',$ctrl->size,'" multiple="multiple">'; 
     219                echo '<select name="',$ctrl->ref,'[]" id="',$this->_name,'_',$ctrl->ref,'"',$readonly,$hint,$class,' size="',$ctrl->size,'" multiple="multiple">'; 
    196220                $value = $this->_form->getData($ctrl->ref); 
    197221                if($value == null){ 
     
    225249                } 
    226250 
    227                 echo '<select',$id,$readonly,$hint,' size="',$ctrl->size,'">'; 
     251                echo '<select',$id,$readonly,$hint,$class,' size="',$ctrl->size,'">'; 
    228252                foreach($ctrl->datasource->getDatas() as $v=>$label){ 
    229253                    echo '<option value="',htmlspecialchars($v),'"',($v==$value?' selected="selected"':''),'>',htmlspecialchars($label),'</option>'; 
     
    236260            if($value === null) 
    237261                $value = $ctrl->defaultValue; 
    238             echo '<textarea',$id,$readonly,$hint,'>',htmlspecialchars($value),'</textarea>'; 
     262            echo '<textarea',$id,$readonly,$hint,$class,'>',htmlspecialchars($value),'</textarea>'; 
    239263            break; 
    240264        case 'secret': 
    241             echo '<input type="password"',$id,$readonly,$hint,' value="',htmlspecialchars($this->_form->getData($ctrl->ref)),'"/>'; 
     265            echo '<input type="password"',$id,$readonly,$hint,$class,' value="',htmlspecialchars($this->_form->getData($ctrl->ref)),'"/>'; 
    242266            break; 
    243267        case 'output': 
     
    249273            break; 
    250274        case 'upload': 
    251             echo '<input type="file"',$id,$readonly,$hint,' value=""/>'; // ',htmlspecialchars($this->_form->getData($ctrl->ref)),' 
     275            echo '<input type="file"',$id,$readonly,$hint,$class,' value=""/>'; // ',htmlspecialchars($this->_form->getData($ctrl->ref)),' 
    252276            break; 
    253277        case 'submit': 
  • trunk/lib/jelix/forms/jFormsControl.class.php

    r523 r526  
    1919   public $type = null; 
    2020   public $ref=''; 
    21    public $datatype='string'
     21   public $datatype
    2222   public $required = false; 
    2323   public $readonly = false; 
     
    3131   function __construct($ref){ 
    3232      $this->ref = $ref; 
     33      $this->datatype = new jDatatypeString(); 
    3334   } 
    3435 
  • trunk/lib/jelix/forms/jFormsControl.class.php

    r523 r526  
    1919   public $type = null; 
    2020   public $ref=''; 
    21    public $datatype='string'
     21   public $datatype
    2222   public $required = false; 
    2323   public $readonly = false; 
     
    3131   function __construct($ref){ 
    3232      $this->ref = $ref; 
     33      $this->datatype = new jDatatypeString(); 
    3334   } 
    3435 
  • trunk/lib/jelix/plugins/tpl/html/block.form.php

    r525 r526  
    4141    } 
    4242 
    43     if(isset($param[3]) && $param[3] ! '') 
     43    if(isset($param[3]) && $param[3] != '') 
    4444        $errdecorator = $param[3]; 
    4545    else 
    4646        $errdecorator = "'jFormsErrorDecoratorAlert'"; 
    4747 
    48     if(isset($param[4]) && $param[4] ! '') 
     48    if(isset($param[4]) && $param[4] != '') 
    4949        $helpdecorator = $param[4]; 
    5050    else 
     
    5555$t->_privateVars[\'__builder\']->outputHeader(array('.$errdecorator.','.$helpdecorator.')); 
    5656if($GLOBALS[\'gJCoord\']->response!= null){ 
    57     $GLOBALS[\'gJCoord\']->response->addJSLink($GLOBALS[\'gJConfig\']->urlengine[\'basePath\'].\'jelix/js/jforms.js\'); 
    58     $GLOBALS[\'gJCoord\']->response->addCSSLink($GLOBALS[\'gJConfig\']->urlengine[\'basePath\'].\'jelix/design/jforms.css\'); 
     57    $GLOBALS[\'gJCoord\']->response->addJSLink($GLOBALS[\'gJConfig\']->urlengine[\'jelixWWWPath\'].\'js/jforms.js\'); 
     58    $GLOBALS[\'gJCoord\']->response->addCSSLink($GLOBALS[\'gJConfig\']->urlengine[\'jelixWWWPath\'].\'design/jform.css\'); 
    5959} 
    6060'; 
  • trunk/lib/jelix/plugins/tpl/html/block.form.php

    r525 r526  
    4141    } 
    4242 
    43     if(isset($param[3]) && $param[3] ! '') 
     43    if(isset($param[3]) && $param[3] != '') 
    4444        $errdecorator = $param[3]; 
    4545    else 
    4646        $errdecorator = "'jFormsErrorDecoratorAlert'"; 
    4747 
    48     if(isset($param[4]) && $param[4] ! '') 
     48    if(isset($param[4]) && $param[4] != '') 
    4949        $helpdecorator = $param[4]; 
    5050    else