Changeset 8978
- Timestamp:
- 05/15/08 12:10:09 (2 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.1/lib/widget/sfWidgetFormSelect.class.php
r8906 r8978 95 95 return $options; 96 96 } 97 98 /** 99 * @see sfWidget 100 * 101 * We always generate an attribute for the value. 102 */ 103 protected function attributesToHtmlCallback($k, $v) 104 { 105 return is_null($v) || ('' === $v && 'value' != $k) ? '' : sprintf(' %s="%s"', $k, $this->escapeOnce($v)); 106 } 97 107 } branches/1.1/test/unit/widget/sfWidgetFormSelectTest.php
r8906 r8978 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test(1 4, new lime_output_color());13 $t = new lime_test(16, new lime_output_color()); 14 14 15 15 $dom = new DomDocument('1.0', 'utf-8'); … … 24 24 $t->is($css->matchSingle('#foo option[value="foobar"][selected="selected"]')->getValue(), 'foo', '->render() renders a select tag with the value selected'); 25 25 $t->is(count($css->matchAll('#foo option')->getNodes()), 2, '->render() renders all choices as option tags'); 26 27 // value attribute is always mandatory 28 $w = new sfWidgetFormSelect(array('choices' => array('' => 'bar'))); 29 $t->like($w->render('foo', 'foobar'), '/<option value="">/', '->render() always generate a value attribute, even for empty keys'); 30 31 // other attributes are removed is empty 32 $w = new sfWidgetFormSelect(array('choices' => array('' => 'bar'))); 33 $t->like($w->render('foo', 'foobar', array('class' => '', 'style' => null)), '/<option value="">/', '->render() always generate a value attribute, even for empty keys'); 26 34 27 35 // multiple select