Changeset 10307
- Timestamp:
- 07/16/08 00:19:02 (2 months ago)
- Files:
-
- branches/1.1/lib/validator/sfValidatorBoolean.class.php (modified) (1 diff)
- branches/1.1/lib/widget/sfWidgetFormInputCheckbox.class.php (modified) (1 diff)
- branches/1.1/lib/widget/sfWidgetFormSelectRadio.class.php (modified) (1 diff)
- branches/1.1/test/unit/validator/sfValidatorBooleanTest.php (modified) (1 diff)
- branches/1.1/test/unit/widget/sfWidgetFormInputCheckboxTest.php (modified) (2 diffs)
- branches/1.1/test/unit/widget/sfWidgetFormSelectRadioTest.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.1/lib/validator/sfValidatorBoolean.class.php
r9048 r10307 38 38 39 39 $this->setOption('required', false); 40 $this->setOption('empty_value', false); 40 41 } 41 42 branches/1.1/lib/widget/sfWidgetFormInputCheckbox.class.php
r9046 r10307 44 44 public function render($name, $value = null, $attributes = array(), $errors = array()) 45 45 { 46 if (!is_null($value) )46 if (!is_null($value) && $value !== false) 47 47 { 48 48 $attributes['checked'] = 'checked'; branches/1.1/lib/widget/sfWidgetFormSelectRadio.class.php
r9925 r10307 72 72 ); 73 73 74 if (strval($key) == strval($value ))74 if (strval($key) == strval($value === false ? 0 : $value)) 75 75 { 76 76 $baseAttributes['checked'] = 'checked'; branches/1.1/test/unit/validator/sfValidatorBooleanTest.php
r6945 r10307 50 50 $t->diag('empty'); 51 51 $v->setOption('required', false); 52 $t->ok($v->clean(null) === null, '->clean() returns nullif no value is given');52 $t->ok($v->clean(null) === false, '->clean() returns false if no value is given'); 53 53 $v->setOption('empty_value', true); 54 54 $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 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test( 3, new lime_output_color());13 $t = new lime_test(4, new lime_output_color()); 14 14 15 15 $w = new sfWidgetFormInputCheckbox(); … … 19 19 $t->is($w->render('foo', 1), '<input type="checkbox" name="foo" checked="checked" id="foo" />', '->render() renders the widget as HTML'); 20 20 $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'); 21 22 $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 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test( 3, new lime_output_color());13 $t = new lime_test(5, new lime_output_color()); 14 14 15 15 $dom = new DomDocument('1.0', 'utf-8'); … … 34 34 $t->is($w->render('foo', 'foobar', array('onChange' => 'alert(42)')), $onChange, '->render() renders a radio tag using extra attributes'); 35 35 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" /> <label for="myname_0">bar</label></li>'."\n". 39 '<li><input name="myname" type="radio" value="1" id="myname_1" /> <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" /> <label for="myname_0">bar</label></li>'."\n". 46 '<li><input name="myname" type="radio" value="1" id="myname_1" checked="checked" /> <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 36 50 // choices as a callable 37 51 $t->diag('choices as a callable');