Development

Changeset 10307

You must first sign up to be able to contribute.

Changeset 10307

Show
Ignore:
Timestamp:
07/16/08 00:19:02 (2 months ago)
Author:
Carl.Vondrick
Message:

1.1: backported r10306

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.1/lib/validator/sfValidatorBoolean.class.php

    r9048 r10307  
    3838 
    3939    $this->setOption('required', false); 
     40    $this->setOption('empty_value', false); 
    4041  } 
    4142 
  • branches/1.1/lib/widget/sfWidgetFormInputCheckbox.class.php

    r9046 r10307  
    4444  public function render($name, $value = null, $attributes = array(), $errors = array()) 
    4545  { 
    46     if (!is_null($value)
     46    if (!is_null($value) && $value !== false
    4747    { 
    4848      $attributes['checked'] = 'checked'; 
  • branches/1.1/lib/widget/sfWidgetFormSelectRadio.class.php

    r9925 r10307  
    7272      ); 
    7373 
    74       if (strval($key) == strval($value)) 
     74      if (strval($key) == strval($value === false ? 0 : $value)) 
    7575      { 
    7676        $baseAttributes['checked'] = 'checked'; 
  • branches/1.1/test/unit/validator/sfValidatorBooleanTest.php

    r6945 r10307  
    5050$t->diag('empty'); 
    5151$v->setOption('required', false); 
    52 $t->ok($v->clean(null) === null, '->clean() returns null if no value is given'); 
     52$t->ok($v->clean(null) === false, '->clean() returns false if no value is given'); 
    5353$v->setOption('empty_value', true); 
    5454$t->ok($v->clean(null) === true, '->clean() returns the value of the empty_value option if no value is given'); 
  • branches/1.1/test/unit/widget/sfWidgetFormInputCheckboxTest.php

    r8487 r10307  
    1111require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
    1212 
    13 $t = new lime_test(3, new lime_output_color()); 
     13$t = new lime_test(4, new lime_output_color()); 
    1414 
    1515$w = new sfWidgetFormInputCheckbox(); 
     
    1919$t->is($w->render('foo', 1), '<input type="checkbox" name="foo" checked="checked" id="foo" />', '->render() renders the widget as HTML'); 
    2020$t->is($w->render('foo', null), '<input type="checkbox" name="foo" id="foo" />', '->render() renders the widget as HTML'); 
     21$t->is($w->render('foo', false), '<input type="checkbox" name="foo" id="foo" />', '->render() renders the widget as HTML'); 
    2122$t->is($w->render('foo', 0, array('value' => '0')), '<input type="checkbox" name="foo" value="0" checked="checked" id="foo" />', '->render() renders the widget as HTML'); 
  • branches/1.1/test/unit/widget/sfWidgetFormSelectRadioTest.php

    r8974 r10307  
    1111require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
    1212 
    13 $t = new lime_test(3, new lime_output_color()); 
     13$t = new lime_test(5, new lime_output_color()); 
    1414 
    1515$dom = new DomDocument('1.0', 'utf-8'); 
     
    3434$t->is($w->render('foo', 'foobar', array('onChange' => 'alert(42)')), $onChange, '->render() renders a radio tag using extra attributes'); 
    3535 
     36$w = new sfWidgetFormSelectRadio(array('choices' => array('0' => 'bar', '1' => 'foo'))); 
     37$output = '<ul class="radio_list">'. 
     38'<li><input name="myname" type="radio" value="0" id="myname_0" checked="checked" />&nbsp;<label for="myname_0">bar</label></li>'."\n". 
     39'<li><input name="myname" type="radio" value="1" id="myname_1" />&nbsp;<label for="myname_1">foo</label></li>'. 
     40'</ul>'; 
     41$t->is($w->render('myname', false), $output, '->render() considers false to be an integer 0'); 
     42 
     43$w = new sfWidgetFormSelectRadio(array('choices' => array('0' => 'bar', '1' => 'foo'))); 
     44$output = '<ul class="radio_list">'. 
     45'<li><input name="myname" type="radio" value="0" id="myname_0" />&nbsp;<label for="myname_0">bar</label></li>'."\n". 
     46'<li><input name="myname" type="radio" value="1" id="myname_1" checked="checked" />&nbsp;<label for="myname_1">foo</label></li>'. 
     47'</ul>'; 
     48$t->is($w->render('myname', true), $output, '->render() considers true to be an integer 1'); 
     49 
    3650// choices as a callable 
    3751$t->diag('choices as a callable');