- Timestamp:
- 11/16/09 14:06:31 (4 years ago)
- Files:
-
- branches/1.3/lib/widget/sfWidgetFormChoiceBase.class.php (modified) (1 diff)
- branches/1.3/test/unit/widget/sfWidgetFormSelectTest.php (modified) (2 diffs)
- branches/1.4/lib/widget/sfWidgetFormChoiceBase.class.php (modified) (1 diff)
- branches/1.4/test/unit/widget/sfWidgetFormSelectTest.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.3/lib/widget/sfWidgetFormChoiceBase.class.php
r23994 r24012 50 50 } 51 51 52 return $this->translateAll($choices); 52 $results = array(); 53 foreach ($choices as $key => $choice) 54 { 55 if (is_array($choice)) 56 { 57 $results[$this->translate($key)] = $this->translateAll($choice); 58 } 59 else 60 { 61 $results[$key] = $this->translate($choice); 62 } 63 } 64 65 return $results; 53 66 } 54 67 branches/1.3/test/unit/widget/sfWidgetFormSelectTest.php
r23994 r24012 21 21 } 22 22 23 $t = new lime_test(2 0);23 $t = new lime_test(22); 24 24 25 25 $dom = new DomDocument('1.0', 'utf-8'); … … 88 88 $t->is($css->matchSingle('#foo option[value="foobar"]')->getValue(), 'translation[foo]', '->render() translates the options'); 89 89 90 // optgroup support with translated choices 91 $t->diag('optgroup support with translated choices'); 92 93 $ws = new sfWidgetFormSchema(); 94 $ws->addFormFormatter('stub', new FormFormatterStub()); 95 $ws->setFormFormatterName('stub'); 96 $w = new sfWidgetFormSelect(array('choices' => array('group' => array('foo' => 'bar', 'foobar' => 'foo')))); 97 $w->setParent($ws); 98 $dom->loadHTML($w->render('foo')); 99 $css = new sfDomCssSelector($dom); 100 $t->is($css->matchSingle('#foo optgroup[label="translation[group]"] option[value="foo"]')->getValue(), 'translation[bar]', '->render() translates the options'); 101 $t->is($css->matchSingle('#foo optgroup[label="translation[group]"] option[value="foobar"]')->getValue(), 'translation[foo]', '->render() translates the options'); 102 90 103 // choices as a callable 91 104 $t->diag('choices as a callable'); branches/1.4/lib/widget/sfWidgetFormChoiceBase.class.php
r23994 r24012 50 50 } 51 51 52 return $this->translateAll($choices); 52 $results = array(); 53 foreach ($choices as $key => $choice) 54 { 55 if (is_array($choice)) 56 { 57 $results[$this->translate($key)] = $this->translateAll($choice); 58 } 59 else 60 { 61 $results[$key] = $this->translate($choice); 62 } 63 } 64 65 return $results; 53 66 } 54 67 branches/1.4/test/unit/widget/sfWidgetFormSelectTest.php
r23994 r24012 21 21 } 22 22 23 $t = new lime_test(2 0);23 $t = new lime_test(22); 24 24 25 25 $dom = new DomDocument('1.0', 'utf-8'); … … 88 88 $t->is($css->matchSingle('#foo option[value="foobar"]')->getValue(), 'translation[foo]', '->render() translates the options'); 89 89 90 // optgroup support with translated choices 91 $t->diag('optgroup support with translated choices'); 92 93 $ws = new sfWidgetFormSchema(); 94 $ws->addFormFormatter('stub', new FormFormatterStub()); 95 $ws->setFormFormatterName('stub'); 96 $w = new sfWidgetFormSelect(array('choices' => array('group' => array('foo' => 'bar', 'foobar' => 'foo')))); 97 $w->setParent($ws); 98 $dom->loadHTML($w->render('foo')); 99 $css = new sfDomCssSelector($dom); 100 $t->is($css->matchSingle('#foo optgroup[label="translation[group]"] option[value="foo"]')->getValue(), 'translation[bar]', '->render() translates the options'); 101 $t->is($css->matchSingle('#foo optgroup[label="translation[group]"] option[value="foobar"]')->getValue(), 'translation[foo]', '->render() translates the options'); 102 90 103 // choices as a callable 91 104 $t->diag('choices as a callable');