Changeset 1104

Show
Ignore:
Timestamp:
09/30/08 16:46:34 (3 months ago)
Author:
julieni
Message:

ticket #691: jForms: radiobutton with value 0 should not get selected by default

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/jelix/CREDITS

    r1103 r1104  
    3535 - jForms: Add support of the required attribute on <checkbox> (#635) 
    3636 - fixes about table_prefix in jDb (#702, #703) 
     37 - jForms: radiobutton with value 0 should not get selected by default (#691) 
    3738 
    3839Bastien Jaillot (aka bastnic) 
  • trunk/lib/jelix/plugins/jforms/html/html.jformsbuilder.php

    r1081 r1104  
    332332                $value=''; 
    333333        } 
     334        $value = (string) $value; 
    334335        $span ='<span class="jforms-radio jforms-ctl-'.$ctrl->ref.'"><input type="radio"'; 
    335336        foreach($ctrl->datasource->getData($this->_form) as $v=>$label){ 
    336             echo $span,$id,$i,'" value="',htmlspecialchars($v),'"',($v==$value?' checked="checked"':''),$readonly,$class,$this->_endt; 
     337            echo $span,$id,$i,'" value="',htmlspecialchars($v),'"',((string) $v===$value?' checked="checked"':''),$readonly,$class,$this->_endt; 
    337338            echo '<label for="',$this->_name,'_',$ctrl->ref,'_',$i,'">',htmlspecialchars($label),'</label></span>'; 
    338339            $i++; 
  • trunk/lib/jelix/plugins/jforms/htmllight/htmllight.jformsbuilder.php

    r1081 r1104  
    331331                $value=''; 
    332332        } 
     333        $value = (string) $value; 
    333334        $span ='<span class="jforms-radio jforms-ctl-'.$ctrl->ref.'"><input type="radio"'; 
    334335        foreach($ctrl->datasource->getData($this->_form) as $v=>$label){ 
    335             echo $span,$id,$i,'" value="',htmlspecialchars($v),'"',($v==$value?' checked="checked"':''),$readonly,$class,$this->_endt; 
     336            echo $span,$id,$i,'" value="',htmlspecialchars($v),'"',((string) $v===$value?' checked="checked"':''),$readonly,$class,$this->_endt; 
    336337            echo '<label for="',$this->_name,'_',$ctrl->ref,'_',$i,'">',htmlspecialchars($label),'</label></span>'; 
    337338            $i++; 
  • trunk/testapp/modules/jelix_tests/tests/jforms.htmlbuilder.html_cli.php

    r1099 r1104  
    470470jFormsJQ.tForm.addControl(c); 
    471471', $this->builder->getJsContent()); 
    472  
     472         
     473        $this->builder->clearJs(); 
     474         
     475        $ctrl->datasource = new jFormsStaticDatasource(); 
     476        $ctrl->datasource->data = array('1'=>'Yes','0'=>'No'); 
     477        $this->form->setReadOnly('rbchoixsimple',false); 
     478        $this->form->setData('rbchoixsimple',null); 
     479        ob_start();$this->builder->outputControl($ctrl);$out = ob_get_clean(); 
     480        $result='<span class="jforms-radio jforms-ctl-rbchoixsimple"><input type="radio" name="rbchoixsimple" id="'.$this->formname.'_rbchoixsimple_0" value="1"/><label for="'.$this->formname.'_rbchoixsimple_0">Yes</label></span>'; 
     481        $result.='<span class="jforms-radio jforms-ctl-rbchoixsimple"><input type="radio" name="rbchoixsimple" id="'.$this->formname.'_rbchoixsimple_1" value="0"/><label for="'.$this->formname.'_rbchoixsimple_1">No</label></span>'; 
     482        $this->assertEqualOrDiff($result, $out); 
     483         
     484        $this->form->setData('rbchoixsimple',0); 
     485        ob_start();$this->builder->outputControl($ctrl);$out = ob_get_clean(); 
     486        $result='<span class="jforms-radio jforms-ctl-rbchoixsimple"><input type="radio" name="rbchoixsimple" id="'.$this->formname.'_rbchoixsimple_0" value="1"/><label for="'.$this->formname.'_rbchoixsimple_0">Yes</label></span>'; 
     487        $result.='<span class="jforms-radio jforms-ctl-rbchoixsimple"><input type="radio" name="rbchoixsimple" id="'.$this->formname.'_rbchoixsimple_1" value="0" checked="checked"/><label for="'.$this->formname.'_rbchoixsimple_1">No</label></span>'; 
     488        $this->assertEqualOrDiff($result, $out); 
     489         
     490        $this->builder->clearJs(); 
    473491    } 
    474492 
  • trunk/testapp/modules/jelix_tests/tests/jforms.htmllightbuilder.html_cli.php

    r1099 r1104  
    470470jForms.tForm.addControl(c); 
    471471', $this->builder->getJsContent()); 
    472  
     472         
     473        $this->builder->clearJs(); 
     474         
     475        $ctrl->datasource = new jFormsStaticDatasource(); 
     476        $ctrl->datasource->data = array('1'=>'Yes','0'=>'No'); 
     477        $this->form->setReadOnly('rbchoixsimple',false); 
     478        $this->form->setData('rbchoixsimple',null); 
     479        ob_start();$this->builder->outputControl($ctrl);$out = ob_get_clean(); 
     480        $result='<span class="jforms-radio jforms-ctl-rbchoixsimple"><input type="radio" name="rbchoixsimple" id="'.$this->formname.'_rbchoixsimple_0" value="1"/><label for="'.$this->formname.'_rbchoixsimple_0">Yes</label></span>'; 
     481        $result.='<span class="jforms-radio jforms-ctl-rbchoixsimple"><input type="radio" name="rbchoixsimple" id="'.$this->formname.'_rbchoixsimple_1" value="0"/><label for="'.$this->formname.'_rbchoixsimple_1">No</label></span>'; 
     482        $this->assertEqualOrDiff($result, $out); 
     483         
     484        $this->form->setData('rbchoixsimple',0); 
     485        ob_start();$this->builder->outputControl($ctrl);$out = ob_get_clean(); 
     486        $result='<span class="jforms-radio jforms-ctl-rbchoixsimple"><input type="radio" name="rbchoixsimple" id="'.$this->formname.'_rbchoixsimple_0" value="1"/><label for="'.$this->formname.'_rbchoixsimple_0">Yes</label></span>'; 
     487        $result.='<span class="jforms-radio jforms-ctl-rbchoixsimple"><input type="radio" name="rbchoixsimple" id="'.$this->formname.'_rbchoixsimple_1" value="0" checked="checked"/><label for="'.$this->formname.'_rbchoixsimple_1">No</label></span>'; 
     488        $this->assertEqualOrDiff($result, $out); 
     489         
     490        $this->builder->clearJs(); 
    473491    } 
    474492 
Download in other formats: Unified Diff Zip Archive