Changeset 605

Show
Ignore:
Timestamp:
10/05/07 16:07:59 (1 year ago)
Author:
laurentj
Message:

fixed bug 295: defaultvalue attribute was not really supported

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.0beta3.x/lib/jelix/forms/jFormsBase.class.php

    r594 r605  
    502502        } 
    503503        if(!isset($this->_container->datas[$control->ref])){ 
    504             $this->_container->datas[$control->ref] = $control->value; 
     504            $this->_container->datas[$control->ref] = $control->defaultValue; 
    505505        } 
    506506    } 
  • branches/1.0beta3.x/lib/jelix/forms/jFormsBase.class.php

    r594 r605  
    502502        } 
    503503        if(!isset($this->_container->datas[$control->ref])){ 
    504             $this->_container->datas[$control->ref] = $control->value; 
     504            $this->_container->datas[$control->ref] = $control->defaultValue; 
    505505        } 
    506506    } 
  • branches/1.0beta3.x/lib/jelix/forms/jFormsBuilderBase.class.php

    r552 r605  
    175175        case 'input': 
    176176            $value = $this->_form->getData($ctrl->ref); 
    177             if($value === null) 
    178                 $value = $ctrl->defaultValue; 
    179177            echo '<input type="text"',$id,$readonly,$hint,$class,' value="',htmlspecialchars($value),'"',$this->_endt; 
    180178            break; 
    181179        case 'checkbox': 
    182180            $value = $this->_form->getData($ctrl->ref); 
    183             if($value =='') 
    184                 $value = $ctrl->defaultValue; 
    185181 
    186182            if($ctrl->valueOnCheck == $value){ 
     
    196192            $attrs=' name="'.$ctrl->ref.'[]" id="'.$id; 
    197193            $value = $this->_form->getData($ctrl->ref); 
    198             if($value == null){ 
    199                 $value = $ctrl->selectedValues; 
    200             } 
    201194 
    202195            if(is_array($value) && count($value) == 1) 
     
    225218            $id=' name="'.$ctrl->ref.'" id="'.$this->_name.'_'.$ctrl->ref.'_'; 
    226219            $value = $this->_form->getData($ctrl->ref); 
    227             if($value === null){ 
    228                 if(count($ctrl->selectedValues) == 1) 
    229                     $value = $ctrl->selectedValues[0]; 
     220            if(is_array($value)){ 
     221                if(isset($value[0])) 
     222                    $value = $value[0]; 
     223                else 
     224                    $value=''; 
    230225            } 
    231226            foreach($ctrl->datasource->getDatas() as $v=>$label){ 
     
    238233            echo '<select',$id,$readonly,$hint,$class,' size="1">'; 
    239234            $value = $this->_form->getData($ctrl->ref); 
    240             if($value === null){ 
    241                 if(count($ctrl->selectedValues) == 1) 
    242                     $value = $ctrl->selectedValues[0]; 
    243             } 
     235            if(is_array($value)){ 
     236                if(isset($value[0])) 
     237                    $value = $value[0]; 
     238                else 
     239                    $value=''; 
     240            } 
     241 
    244242            foreach($ctrl->datasource->getDatas() as $v=>$label){ 
    245243                echo '<option value="',htmlspecialchars($v),'"',($v==$value?' selected="selected"':''),'>',htmlspecialchars($label),'</option>'; 
     
    251249                echo '<select name="',$ctrl->ref,'[]" id="',$this->_name,'_',$ctrl->ref,'"',$readonly,$hint,$class,' size="',$ctrl->size,'" multiple="multiple">'; 
    252250                $value = $this->_form->getData($ctrl->ref); 
    253                 if($value == null){ 
    254                     $value = $ctrl->selectedValues; 
    255                 } 
    256251 
    257252                if(is_array($value) && count($value) == 1) 
     
    270265            }else{ 
    271266                $value = $this->_form->getData($ctrl->ref); 
    272                 if($value == null){ 
    273                     $value = $ctrl->selectedValues; 
    274                 } 
    275267 
    276268                if(is_array($value)){ 
     
    290282        case 'textarea': 
    291283            $value = $this->_form->getData($ctrl->ref); 
    292             if($value === null) 
    293                 $value = $ctrl->defaultValue; 
    294284            echo '<textarea',$id,$readonly,$hint,$class,'>',htmlspecialchars($value),'</textarea>'; 
    295285            break; 
     
    300290        case 'output': 
    301291            $value = $this->_form->getData($ctrl->ref); 
    302             if($value === null) 
    303                 $value = $ctrl->defaultValue; 
    304292            echo '<input type="hidden"',$id,' value="',htmlspecialchars($value),'"',$this->_endt; 
    305293            echo '<span class="jforms-value"',$hint,'>',htmlspecialchars($value),'</span>'; 
  • branches/1.0beta3.x/lib/jelix/forms/jFormsBuilderBase.class.php

    r552 r605  
    175175        case 'input': 
    176176            $value = $this->_form->getData($ctrl->ref); 
    177             if($value === null) 
    178                 $value = $ctrl->defaultValue; 
    179177            echo '<input type="text"',$id,$readonly,$hint,$class,' value="',htmlspecialchars($value),'"',$this->_endt; 
    180178            break; 
    181179        case 'checkbox': 
    182180            $value = $this->_form->getData($ctrl->ref); 
    183             if($value =='') 
    184                 $value = $ctrl->defaultValue; 
    185181 
    186182            if($ctrl->valueOnCheck == $value){ 
     
    196192            $attrs=' name="'.$ctrl->ref.'[]" id="'.$id; 
    197193            $value = $this->_form->getData($ctrl->ref); 
    198             if($value == null){ 
    199                 $value = $ctrl->selectedValues; 
    200             } 
    201194 
    202195            if(is_array($value) && count($value) == 1) 
     
    225218            $id=' name="'.$ctrl->ref.'" id="'.$this->_name.'_'.$ctrl->ref.'_'; 
    226219            $value = $this->_form->getData($ctrl->ref); 
    227             if($value === null){ 
    228                 if(count($ctrl->selectedValues) == 1) 
    229                     $value = $ctrl->selectedValues[0]; 
     220            if(is_array($value)){ 
     221                if(isset($value[0])) 
     222                    $value = $value[0]; 
     223                else 
     224                    $value=''; 
    230225            } 
    231226            foreach($ctrl->datasource->getDatas() as $v=>$label){ 
     
    238233            echo '<select',$id,$readonly,$hint,$class,' size="1">'; 
    239234            $value = $this->_form->getData($ctrl->ref); 
    240             if($value === null){ 
    241                 if(count($ctrl->selectedValues) == 1) 
    242                     $value = $ctrl->selectedValues[0]; 
    243             } 
     235            if(is_array($value)){ 
     236                if(isset($value[0])) 
     237                    $value = $value[0]; 
     238                else 
     239                    $value=''; 
     240            } 
     241 
    244242            foreach($ctrl->datasource->getDatas() as $v=>$label){ 
    245243                echo '<option value="',htmlspecialchars($v),'"',($v==$value?' selected="selected"':''),'>',htmlspecialchars($label),'</option>'; 
     
    251249                echo '<select name="',$ctrl->ref,'[]" id="',$this->_name,'_',$ctrl->ref,'"',$readonly,$hint,$class,' size="',$ctrl->size,'" multiple="multiple">'; 
    252250                $value = $this->_form->getData($ctrl->ref); 
    253                 if($value == null){ 
    254                     $value = $ctrl->selectedValues; 
    255                 } 
    256251 
    257252                if(is_array($value) && count($value) == 1) 
     
    270265            }else{ 
    271266                $value = $this->_form->getData($ctrl->ref); 
    272                 if($value == null){ 
    273                     $value = $ctrl->selectedValues; 
    274                 } 
    275267 
    276268                if(is_array($value)){ 
     
    290282        case 'textarea': 
    291283            $value = $this->_form->getData($ctrl->ref); 
    292             if($value === null) 
    293                 $value = $ctrl->defaultValue; 
    294284            echo '<textarea',$id,$readonly,$hint,$class,'>',htmlspecialchars($value),'</textarea>'; 
    295285            break; 
     
    300290        case 'output': 
    301291            $value = $this->_form->getData($ctrl->ref); 
    302             if($value === null) 
    303                 $value = $ctrl->defaultValue; 
    304292            echo '<input type="hidden"',$id,' value="',htmlspecialchars($value),'"',$this->_endt; 
    305293            echo '<span class="jforms-value"',$hint,'>',htmlspecialchars($value),'</span>'; 
  • branches/1.0beta3.x/lib/jelix/forms/jFormsCompiler.class.php

    r580 r605  
    210210                        $str.="'". str_replace("'","\\'", (string)$value) ."',"; 
    211211                    } 
    212                     $source[]='$ctrl->selectedValues='.$str.');'; 
     212                    $source[]='$ctrl->defaultValue='.$str.');'; 
    213213                    $hasSelectedValues = true; 
    214214                }elseif(isset($control['selectedvalue'])){ 
    215                     $source[]='$ctrl->selectedValues=array(\''. str_replace("'","\\'", (string)$control['selectedvalue']) .'\');'; 
     215                    $source[]='$ctrl->defaultValue=array(\''. str_replace("'","\\'", (string)$control['selectedvalue']) .'\');'; 
    216216                    $hasSelectedValues = true; 
    217217                } 
     
    264264                            throw new jException('jelix~formserr.multiple.selected.not.allowed',$this->sourceFile); 
    265265                        } 
    266                         $source[]='$ctrl->selectedValues='.var_export($selectedvalues,true).';'; 
     266                        $source[]='$ctrl->defaultValue='.var_export($selectedvalues,true).';'; 
    267267                    } 
    268268                }else{ 
     
    290290                    if($alertRequired!='') 
    291291                        $source[]='$ctrl2->alertRequired = $ctrl->alertRequired;'; 
    292                      
     292 
    293293                    if(isset($control->help)){ 
    294294                        $source[]='$ctrl2->hasHelp=true;'; 
  • branches/1.0beta3.x/lib/jelix/forms/jFormsCompiler.class.php

    r580 r605  
    210210                        $str.="'". str_replace("'","\\'", (string)$value) ."',"; 
    211211                    } 
    212                     $source[]='$ctrl->selectedValues='.$str.');'; 
     212                    $source[]='$ctrl->defaultValue='.$str.');'; 
    213213                    $hasSelectedValues = true; 
    214214                }elseif(isset($control['selectedvalue'])){ 
    215                     $source[]='$ctrl->selectedValues=array(\''. str_replace("'","\\'", (string)$control['selectedvalue']) .'\');'; 
     215                    $source[]='$ctrl->defaultValue=array(\''. str_replace("'","\\'", (string)$control['selectedvalue']) .'\');'; 
    216216                    $hasSelectedValues = true; 
    217217                } 
     
    264264                            throw new jException('jelix~formserr.multiple.selected.not.allowed',$this->sourceFile); 
    265265                        } 
    266                         $source[]='$ctrl->selectedValues='.var_export($selectedvalues,true).';'; 
     266                        $source[]='$ctrl->defaultValue='.var_export($selectedvalues,true).';'; 
    267267                    } 
    268268                }else{ 
     
    290290                    if($alertRequired!='') 
    291291                        $source[]='$ctrl2->alertRequired = $ctrl->alertRequired;'; 
    292                      
     292 
    293293                    if(isset($control->help)){ 
    294294                        $source[]='$ctrl2->hasHelp=true;'; 
  • branches/1.0beta3.x/lib/jelix/forms/jFormsControl.class.php

    r552 r605  
    2828    public $readonly = false; 
    2929    public $label=''; 
    30     public $value=''; 
     30    public $defaultValue=''; 
    3131    public $hasHelp = false; 
    3232    public $hint=''; 
     
    7171     */ 
    7272    public $datasource; 
    73     public $selectedValues=array(); 
     73    public $defaultValue=array(); 
    7474 
    7575    function getDisplayValue($value){ 
     
    9393class jFormsControlInput extends jFormsControl { 
    9494    public $type='input'; 
    95     public $defaultValue=''; 
    9695} 
    9796 
     
    195194class jFormsControlTextarea extends jFormsControl { 
    196195    public $type='textarea'; 
    197     public $defaultValue=''; 
    198196} 
    199197 
     
    247245class jFormsControlOutput extends jFormsControl { 
    248246    public $type='output'; 
    249     public $defaultValue=''; 
    250247 
    251248    public function check($value, $form){ 
  • branches/1.0beta3.x/lib/jelix/forms/jFormsControl.class.php

    r552 r605  
    2828    public $readonly = false; 
    2929    public $label=''; 
    30     public $value=''; 
     30    public $defaultValue=''; 
    3131    public $hasHelp = false; 
    3232    public $hint=''; 
     
    7171     */ 
    7272    public $datasource; 
    73     public $selectedValues=array(); 
     73    public $defaultValue=array(); 
    7474 
    7575    function getDisplayValue($value){ 
     
    9393class jFormsControlInput extends jFormsControl { 
    9494    public $type='input'; 
    95     public $defaultValue=''; 
    9695} 
    9796 
     
    195194class jFormsControlTextarea extends jFormsControl { 
    196195    public $type='textarea'; 
    197     public $defaultValue=''; 
    198196} 
    199197 
     
    247245class jFormsControlOutput extends jFormsControl { 
    248246    public $type='output'; 
    249     public $defaultValue=''; 
    250247 
    251248    public function check($value, $form){ 
  • branches/1.0beta3.x/testapp/modules/jelix_tests/tests/jforms.compiler.html.php

    r580 r605  
    422422\'ccc\'=>\'ccc\', 
    423423); 
    424 $ctrl->selectedValues=array ( 
     424$ctrl->defaultValue=array ( 
    425425  0 => \'aaa\', 
    426426); 
     
    434434\'ccc\'=>\'ccc\', 
    435435); 
    436 $ctrl->selectedValues=array ( 
     436$ctrl->defaultValue=array ( 
    437437  0 => \'aaa\', 
    438438  1 => \'ccc\', 
     
    44244240=>'$ctrl= new jFormsControllistbox(\'nom\'); 
    443443$ctrl->label=\'Votre nom\'; 
    444 $ctrl->selectedValues=array(\'aaa\'); 
     444$ctrl->defaultValue=array(\'aaa\'); 
    445445$ctrl->datasource= new jFormStaticDatasource(); 
    446446$ctrl->datasource->datas = array( 
     
    45345341=>'$ctrl= new jFormsControllistbox(\'nom\'); 
    454454$ctrl->label=\'Votre nom\'; 
    455 $ctrl->selectedValues= array(\'bbb\',\'aaa\',); 
     455$ctrl->defaultValue= array(\'bbb\',\'aaa\',); 
    456456$ctrl->datasource= new jFormStaticDatasource(); 
    457457$ctrl->datasource->datas = array( 
  • branches/1.0beta3.x/testapp/modules/jelix_tests/tests/jforms.compiler.html.php

    r580 r605  
    422422\'ccc\'=>\'ccc\', 
    423423); 
    424 $ctrl->selectedValues=array ( 
     424$ctrl->defaultValue=array ( 
    425425  0 => \'aaa\', 
    426426); 
     
    434434\'ccc\'=>\'ccc\', 
    435435); 
    436 $ctrl->selectedValues=array ( 
     436$ctrl->defaultValue=array ( 
    437437  0 => \'aaa\', 
    438438  1 => \'ccc\', 
     
    44244240=>'$ctrl= new jFormsControllistbox(\'nom\'); 
    443443$ctrl->label=\'Votre nom\'; 
    444 $ctrl->selectedValues=array(\'aaa\'); 
     444$ctrl->defaultValue=array(\'aaa\'); 
    445445$ctrl->datasource= new jFormStaticDatasource(); 
    446446$ctrl->datasource->datas = array( 
     
    45345341=>'$ctrl= new jFormsControllistbox(\'nom\'); 
    454454$ctrl->label=\'Votre nom\'; 
    455 $ctrl->selectedValues= array(\'bbb\',\'aaa\',); 
     455$ctrl->defaultValue= array(\'bbb\',\'aaa\',); 
    456456$ctrl->datasource= new jFormStaticDatasource(); 
    457457$ctrl->datasource->datas = array( 
  • branches/1.0beta3.x/testapp/modules/jelix_tests/tests/jforms.html.php

    r483 r605  
    4242            <boolean property="readonly" value="false"/> 
    4343            <string property="label" value="product name"/> 
    44             <string property="value" value=""/> 
    45         </object> 
    46         <object key="price" class="jFormsControlInput"> 
    47             <string property="ref" value="price"/> 
    48             <boolean property="required" value="false"/> 
    49             <boolean property="readonly" value="false"/> 
    50             <string property="label" value="The price"/> 
    51             <string property="value" value=""/> 
     44            <string property="defaultValue" value=""/> 
     45        </object> 
     46        <object key="price" class="jFormsControlInput"> 
     47            <string property="ref" value="price"/> 
     48            <boolean property="required" value="false"/> 
     49            <boolean property="readonly" value="false"/> 
     50            <string property="label" value="The price"/> 
     51            <string property="defaultValue" value=""/> 
    5252        </object> 
    5353    </array> 
     
    7777            <boolean property="readonly" value="false"/> 
    7878            <string property="label" value="product name"/> 
    79             <string property="value" value=""/> 
    80         </object> 
    81         <object key="price" class="jFormsControlInput"> 
    82             <string property="ref" value="price"/> 
    83             <boolean property="required" value="false"/> 
    84             <boolean property="readonly" value="false"/> 
    85             <string property="label" value="The price"/> 
    86             <string property="value" value=""/> 
     79            <string property="defaultValue" value=""/> 
     80        </object> 
     81        <object key="price" class="jFormsControlInput"> 
     82            <string property="ref" value="price"/> 
     83            <boolean property="required" value="false"/> 
     84            <boolean property="readonly" value="false"/> 
     85            <string property="label" value="The price"/> 
     86            <string property="defaultValue" value=""/> 
    8787        </object> 
    8888    </array> 
     
    186186            <boolean property="readonly" value="false"/> 
    187187            <string property="label" value="product name"/> 
    188             <string property="value" value=""/> 
    189         </object> 
    190         <object key="price" class="jFormsControlInput"> 
    191             <string property="ref" value="price"/> 
    192             <boolean property="required" value="false"/> 
    193             <boolean property="readonly" value="false"/> 
    194             <string property="label" value="The price"/> 
    195             <string property="value" value=""/> 
     188            <string property="defaultValue" value=""/> 
     189        </object> 
     190        <object key="price" class="jFormsControlInput"> 
     191            <string property="ref" value="price"/> 
     192            <boolean property="required" value="false"/> 
     193            <boolean property="readonly" value="false"/> 
     194            <string property="label" value="The price"/> 
     195            <string property="defaultValue" value=""/> 
    196196        </object> 
    197197    </array> 
     
    226226            <boolean property="readonly" value="false"/> 
    227227            <string property="label" value="product name"/> 
    228             <string property="value" value=""/> 
    229         </object> 
    230         <object key="price" class="jFormsControlInput"> 
    231             <string property="ref" value="price"/> 
    232             <boolean property="required" value="false"/> 
    233             <boolean property="readonly" value="false"/> 
    234             <string property="label" value="The price"/> 
    235             <string property="value" value=""/> 
     228            <string property="defaultValue" value=""/> 
     229        </object> 
     230        <object key="price" class="jFormsControlInput"> 
     231            <string property="ref" value="price"/> 
     232            <boolean property="required" value="false"/> 
     233            <boolean property="readonly" value="false"/> 
     234            <string property="label" value="The price"/> 
     235            <string property="defaultValue" value=""/> 
    236236        </object> 
    237237    </array> 
  • branches/1.0beta3.x/testapp/modules/jelix_tests/tests/jforms.html.php

    r483 r605  
    4242            <boolean property="readonly" value="false"/> 
    4343            <string property="label" value="product name"/> 
    44             <string property="value" value=""/> 
    45         </object> 
    46         <object key="price" class="jFormsControlInput"> 
    47             <string property="ref" value="price"/> 
    48             <boolean property="required" value="false"/> 
    49             <boolean property="readonly" value="false"/> 
    50             <string property="label" value="The price"/> 
    51             <string property="value" value=""/> 
     44            <string property="defaultValue" value=""/> 
     45        </object> 
     46        <object key="price" class="jFormsControlInput"> 
     47            <string property="ref" value="price"/> 
     48            <boolean property="required" value="false"/> 
     49            <boolean property="readonly" value="false"/> 
     50            <string property="label" value="The price"/> 
     51            <string property="defaultValue" value=""/> 
    5252        </object> 
    5353    </array> 
     
    7777            <boolean property="readonly" value="false"/> 
    7878            <string property="label" value="product name"/> 
    79             <string property="value" value=""/> 
    80         </object> 
    81         <object key="price" class="jFormsControlInput"> 
    82             <string property="ref" value="price"/> 
    83             <boolean property="required" value="false"/> 
    84             <boolean property="readonly" value="false"/> 
    85             <string property="label" value="The price"/> 
    86             <string property="value" value=""/> 
     79            <string property="defaultValue" value=""/> 
     80        </object> 
     81        <object key="price" class="jFormsControlInput"> 
     82            <string property="ref" value="price"/> 
     83            <boolean property="required" value="false"/> 
     84            <boolean property="readonly" value="false"/> 
     85            <string property="label" value="The price"/> 
     86            <string property="defaultValue" value=""/> 
    8787        </object> 
    8888    </array> 
     
    186186            <boolean property="readonly" value="false"/> 
    187187            <string property="label" value="product name"/> 
    188             <string property="value" value=""/> 
    189         </object> 
    190         <object key="price" class="jFormsControlInput"> 
    191             <string property="ref" value="price"/> 
    192             <boolean property="required" value="false"/> 
    193             <boolean property="readonly" value="false"/> 
    194             <string property="label" value="The price"/> 
    195             <string property="value" value=""/> 
     188            <string property="defaultValue" value=""/> 
     189        </object> 
     190        <object key="price" class="jFormsControlInput"> 
     191            <string property="ref" value="price"/> 
     192            <boolean property="required" value="false"/> 
     193            <boolean property="readonly" value="false"/> 
     194            <string property="label" value="The price"/> 
     195            <string property="defaultValue" value=""/> 
    196196        </object> 
    197197    </array> 
     
    226226            <boolean property="readonly" value="false"/> 
    227227            <string property="label" value="product name"/> 
    228             <string property="value" value=""/> 
    229         </object> 
    230         <object key="price" class="jFormsControlInput"> 
    231             <string property="ref" value="price"/> 
    232             <boolean property="required" value="false"/> 
    233             <boolean property="readonly" value="false"/> 
    234             <string property="label" value="The price"/> 
    235             <string property="value" value=""/> 
     228            <string property="defaultValue" value=""/> 
     229        </object> 
     230        <object key="price" class="jFormsControlInput"> 
     231            <string property="ref" value="price"/> 
     232            <boolean property="required" value="false"/> 
     233            <boolean property="readonly" value="false"/> 
     234            <string property="label" value="The price"/> 
     235            <string property="defaultValue" value=""/> 
    236236        </object> 
    237237    </array> 
  • branches/1.0beta3.x/testapp/modules/jelix_tests/tests/jforms.htmlbuilder.html.php

    r556 r605  
    1818class testHMLForm { // simulate a jFormBase object 
    1919    public $controls= array(); 
     20    public $submits= array(); 
     21    public $uploads= array(); 
    2022    public $container; 
    2123 
     24    protected $datas =  array( 'chk'=>'1', 'chk2'=>'', 'choixsimple'=>'11', 'choixmultiple'=>array('10','23')); 
    2225    function __construct(){ 
    2326        $this->container = new jFormsDataContainer('',''); 
     
    2528 
    2629    function getData($name) { 
    27         $a = array('nom'=>'laurent', 'chk'=>'1', 'chk2'=>'', 'chk3'=>'0', 'choixsimple'=>'11', 'choixmultiple'=>array('10','23')); 
    28         if(isset($a[$name])) 
    29             return $a[$name]; 
     30        if(isset($this->datas[$name])) 
     31            return $this->datas[$name]; 
    3032        else 
    3133            return null; 
    3234    } 
     35    function setData($name,$value) { 
     36        $this->datas[$name]=$value; 
     37    } 
    3338    function getControls() { 
    3439        return $this->controls; 
     
    3944    function hasUpload(){ 
    4045       return false; 
     46    } 
     47    function addControl($control){ 
     48        $this->controls [$control->ref] = $control; 
     49        if($control->type =='submit') 
     50            $this->submits [$control->ref] = $control; 
     51        if($control->type =='upload'){ 
     52            $this->uploads [$control->ref] = $control; 
     53        } 
     54        $this->datas[$control->ref] = $control->defaultValue; 
    4155    } 
    4256} 
     
    5165class UTjformsHTMLBuilder extends jUnitTestCaseDb { 
    5266 
     67    protected $form; 
    5368    protected $builder; 
    5469    function testStart() { 
    55         $form = new testHMLForm(); 
    56         $this->builder = new testJFormsHtmlBuilder($form, 'jelix_tests~urlsig_url1',array()); 
     70        $this->form = new testHMLForm(); 
     71        $this->builder = new testJFormsHtmlBuilder($this->form, 'jelix_tests~urlsig_url1',array()); 
    5772        $this->formname = $this->builder->getName(); 
    5873    } 
     
    105120 
    106121        ob_start();$this->builder->outputControl($ctrl);$out = ob_get_clean(); 
     122        $this->assertEqualOrDiff('<input type="text" name="nom" id="'.$this->formname.'_nom" value=""/>', $out); 
     123 
     124        $this->form->addControl($ctrl); 
     125        ob_start();$this->builder->outputControl($ctrl);$out = ob_get_clean(); 
     126        $this->assertEqualOrDiff('<input type="text" name="nom" id="'.$this->formname.'_nom" value=""/>', $out); 
     127 
     128        $this->form->setData('nom','toto'); 
     129        ob_start();$this->builder->outputControl($ctrl);$out = ob_get_clean(); 
     130        $this->assertEqualOrDiff('<input type="text" name="nom" id="'.$this->formname.'_nom" value="toto"/>', $out); 
     131 
     132        $ctrl->defaultValue='laurent'; 
     133        ob_start();$this->builder->outputControl($ctrl);$out = ob_get_clean(); 
     134        $this->assertEqualOrDiff('<input type="text" name="nom" id="'.$this->formname.'_nom" value="toto"/>', $out); 
     135 
     136        $this->form->addControl($ctrl); 
     137        ob_start();$this->builder->outputControl($ctrl);$out = ob_get_clean(); 
    107138        $this->assertEqualOrDiff('<input type="text" name="nom" id="'.$this->formname.'_nom" value="laurent"/>', $out); 
    108139 
     
    111142        $this->assertEqualOrDiff('<input type="text" name="nom" id="'.$this->formname.'_nom" readonly="readonly" value="laurent"/>', $out); 
    112143 
    113         $ctrl= new jFormsControlinput('nominconnu'); 
    114         $ctrl->datatype= new jDatatypeString(); 
    115         $ctrl->label='Votre nom'; 
    116         $ctrl->defaultValue='toto'; 
    117         ob_start();$this->builder->outputControl($ctrl);$out = ob_get_clean(); 
    118         $this->assertEqualOrDiff('<input type="text" name="nominconnu" id="'.$this->formname.'_nominconnu" value="toto"/>', $out); 
    119  
     144        $ctrl->readonly=false; 
    120145        $ctrl->hasHelp=true; 
    121146        ob_start();$this->builder->outputControl($ctrl);$out = ob_get_clean(); 
    122         $this->assertEqualOrDiff('<input type="text" name="nominconnu" id="'.$this->formname.'_nominconnu" value="toto"/><span class="jforms-help"><a href="javascript:jForms.showHelp(\''. $this->formname.'\',\'nominconnu\')">?</a></span>', $out); 
    123  
    124         $ctrl->hint='ceci est un tooltip'; 
    125         ob_start();$this->builder->outputControlLabel($ctrl);$out = ob_get_clean(); 
    126         $this->assertEqualOrDiff('<label class="jforms-label" for="'.$this->formname.'_nominconnu" title="ceci est un tooltip">Votre nom</label>', $out); 
    127  
    128         ob_start();$this->builder->outputControl($ctrl);$out = ob_get_clean(); 
    129         $this->assertEqualOrDiff('<input type="text" name="nominconnu" id="'.$this->formname.'_nominconnu" title="ceci est un tooltip" value="toto"/><span class="jforms-help"><a href="javascript:jForms.showHelp(\''. $this->formname.'\',\'nominconnu\')">?</a></span>', $out); 
     147        $this->assertEqualOrDiff('<input type="text" name="nom" id="'.$this->formname.'_nom" value="laurent"/><span class="jforms-help"><a href="javascript:jForms.showHelp(\''. $this->formname.'\',\'nom\')">?</a></span>', $out); 
     148 
     149        $ctrl->hint='ceci est un tooltip'; 
     150        ob_start();$this->builder->outputControlLabel($ctrl);$out = ob_get_clean(); 
     151        $this->assertEqualOrDiff('<label class="jforms-label" for="'.$this->formname.'_nom" title="ceci est un tooltip">Votre nom</label>', $out); 
     152 
     153        ob_start();$this->builder->outputControl($ctrl);$out = ob_get_clean(); 
     154        $this->assertEqualOrDiff('<input type="text" name="nom" id="'.$this->formname.'_nom" title="ceci est un tooltip" value="laurent"/><span class="jforms-help"><a href="javascript:jForms.showHelp(\''. $this->formname.'\',\'nom\')">?</a></span>', $out); 
    130155 
    131156    } 
     
    134159        $ctrl->datatype= new jDatatypeString(); 
    135160        $ctrl->label='Une option'; 
     161        $this->form->addControl($ctrl); 
    136162 
    137163        ob_start();$this->builder->outputControlLabel($ctrl);$out = ob_get_clean(); 
     
    139165 
    140166        ob_start();$this->builder->outputControl($ctrl);$out = ob_get_clean(); 
     167        $this->assertEqualOrDiff('<input type="checkbox" name="chk" id="'.$this->formname.'_chk" value="1"/>', $out); 
     168 
     169        $this->form->setData('chk','1'); 
     170        ob_start();$this->builder->outputControl($ctrl);$out = ob_get_clean(); 
    141171        $this->assertEqualOrDiff('<input type="checkbox" name="chk" id="'.$this->formname.'_chk" checked="checked" value="1"/>', $out); 
    142172 
     
    152182 
    153183        $ctrl->defaultValue='1'; 
     184        $this->form->addControl($ctrl); 
    154185        ob_start();$this->builder->outputControl($ctrl);$out = ob_get_clean(); 
    155186        $this->assertEqualOrDiff('<input type="checkbox" name="chk2" id="'.$this->formname.'_chk2" checked="checked" value="1"/>', $out); 
    156187 
    157  
    158         $ctrl= new jFormsControlCheckbox('chk3'); 
    159         $ctrl->datatype= new jDatatypeString(); 
    160         $ctrl->label='Une option'; 
    161  
    162         ob_start();$this->builder->outputControlLabel($ctrl);$out = ob_get_clean(); 
    163         $this->assertEqualOrDiff('<label class="jforms-label" for="'.$this->formname.'_chk3">Une option</label>', $out); 
    164  
    165         ob_start();$this->builder->outputControl($ctrl);$out = ob_get_clean(); 
    166         $this->assertEqualOrDiff('<input type="checkbox" name="chk3" id="'.$this->formname.'_chk3" value="1"/>', $out); 
    167  
    168         $ctrl->defaultValue='1'; 
    169         ob_start();$this->builder->outputControl($ctrl);$out = ob_get_clean(); 
    170         $this->assertEqualOrDiff('<input type="checkbox" name="chk3" id="'.$this->formname.'_chk3" value="1"/>', $out); 
    171  
    172  
    173         $ctrl= new jFormsControlCheckbox('chkinconnu'); 
    174         $ctrl->datatype= new jDatatypeString(); 
    175         $ctrl->label='Une option'; 
    176  
    177         ob_start();$this->builder->outputControl($ctrl);$out = ob_get_clean(); 
    178         $this->assertEqualOrDiff('<input type="checkbox" name="chkinconnu" id="'.$this->formname.'_chkinconnu" value="1"/>', $out); 
     188        $this->form->setData('chk2', '0'); 
     189        ob_start();$this->builder->outputControl($ctrl);$out = ob_get_clean(); 
     190        $this->assertEqualOrDiff('<input type="checkbox" name="chk2" id="'.$this->formname.'_chk2" value="1"/>', $out); 
    179191 
    180192        $ctrl->readonly=true; 
    181193        ob_start();$this->builder->outputControl($ctrl);$out = ob_get_clean(); 
    182         $this->assertEqualOrDiff('<input type="checkbox" name="chkinconnu" id="'.$this->formname.'_chkinconnu" readonly="readonly" value="1"/>', $out); 
    183  
    184         $ctrl->defaultValue='1'; 
    185         ob_start();$this->builder->outputControl($ctrl);$out = ob_get_clean(); 
    186         $this->assertEqualOrDiff('<input type="checkbox" name="chkinconnu" id="'.$this->formname.'_chkinconnu" readonly="readonly" checked="checked" value="1"/>', $out); 
    187  
    188  
    189         $ctrl->hint='ceci est un tooltip'; 
    190         ob_start();$this->builder->outputControlLabel($ctrl);$out = ob_get_clean(); 
    191         $this->assertEqualOrDiff('<label class="jforms-label" for="'.$this->formname.'_chkinconnu" title="ceci est un tooltip">Une option</label>', $out); 
    192  
    193         ob_start();$this->builder->outputControl($ctrl);$out = ob_get_clean(); 
    194         $this->assertEqualOrDiff('<input type="checkbox" name="chkinconnu" id="'.$this->formname.'_chkinconnu" readonly="readonly" title="ceci est un tooltip" checked="checked" value="1"/>', $out); 
    195  
    196  
    197     } 
     194        $this->assertEqualOrDiff('<input type="checkbox" name="chk2" id="'.$this->formname.'_chk2" readonly="readonly" value="1"/>', $out); 
     195 
     196        $this->form->setData('chk2', '1'); 
     197        ob_start();$this->builder->outputControl($ctrl);$out = ob_get_clean(); 
     198        $this->assertEqualOrDiff('<input type="checkbox" name="chk2" id="'.$this->formname.'_chk2" readonly="readonly" checked="checked" value="1"/>', $out); 
     199 
     200        $ctrl->hint='ceci est un tooltip'; 
     201        ob_start();$this->builder->outputControlLabel($ctrl);$out