Changeset 8906
- Timestamp:
- 05/10/08 23:24:28 (3 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.1/lib/widget/sfWidgetFormSelect.class.php
r5952 r8906 59 59 } 60 60 61 /** 62 * Returns an array of option tags for the given choices 63 * 64 * @param string The selected value 65 * @param array An array of choices 66 * 67 * @return array An array of option tags 68 */ 61 69 protected function getOptionsForSelect($value, $choices) 62 70 { 71 $mainAttributes = $this->attributes; 72 $this->attributes = array(); 73 63 74 $options = array(); 64 75 foreach ($choices as $key => $option) … … 80 91 } 81 92 93 $this->attributes = $mainAttributes; 94 82 95 return $options; 83 96 } branches/1.1/test/unit/widget/sfWidgetFormSelectTest.php
r6197 r8906 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test(1 0, new lime_output_color());13 $t = new lime_test(14, new lime_output_color()); 14 14 15 15 $dom = new DomDocument('1.0', 'utf-8'); … … 68 68 $css = new sfDomCssSelector($dom); 69 69 $t->is(count($css->matchAll('#foo option')->getNodes()), 3, '->render() accepts a sfCallable as a choices option'); 70 71 // attributes 72 $t->diag('attributes'); 73 $w = new sfWidgetFormSelect(array('choices' => array(0, 1, 2))); 74 $dom->loadHTML($w->render('foo', null, array('disabled' => 'disabled'))); 75 $css = new sfDomCssSelector($dom); 76 $t->is(count($css->matchAll('select[disabled="disabled"]')->getNodes()), 1, '->render() does not pass the select HTML attributes to the option tag'); 77 $t->is(count($css->matchAll('option[disabled="disabled"]')->getNodes()), 0, '->render() does not pass the select HTML attributes to the option tag'); 78 79 $w = new sfWidgetFormSelect(array('choices' => array(0, 1, 2)), array('disabled' => 'disabled')); 80 $dom->loadHTML($w->render('foo')); 81 $css = new sfDomCssSelector($dom); 82 $t->is(count($css->matchAll('select[disabled="disabled"]')->getNodes()), 1, '->render() does not pass the select HTML attributes to the option tag'); 83 $t->is(count($css->matchAll('option[disabled="disabled"]')->getNodes()), 0, '->render() does not pass the select HTML attributes to the option tag');