Development

Changeset 8974

You must first sign up to be able to contribute.

Changeset 8974

Show
Ignore:
Timestamp:
05/15/08 09:41:31 (4 months ago)
Author:
FabianLange
Message:

sfWidgetFormSelectRadio now merges attributes passed in correctly. Fixes #3528

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.1/lib/widget/sfWidgetFormSelectRadio.class.php

    r5963 r8974  
    5454    foreach ($choices as $key => $option) 
    5555    { 
    56       $attributes = array( 
     56      $baseAttributes = array( 
    5757        'name'  => $name, 
    5858        'type'  => 'radio', 
     
    6363      if (strval($key) == strval($value)) 
    6464      { 
    65         $attributes['checked'] = 'checked'; 
     65        $baseAttributes['checked'] = 'checked'; 
    6666      } 
    6767 
    6868      $inputs[] = array( 
    69         'input' => $this->renderTag('input', $attributes), 
     69        'input' => $this->renderTag('input', array_merge($baseAttributes,$attributes)), 
    7070        'label' => $this->renderContentTag('label', $option, array('for' => $id)), 
    7171      ); 
  • branches/1.1/test/unit/widget/sfWidgetFormSelectRadioTest.php

    r8973 r8974  
    1111require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
    1212 
    13 $t = new lime_test(2, new lime_output_color()); 
     13$t = new lime_test(3, new lime_output_color()); 
    1414 
    1515$dom = new DomDocument('1.0', 'utf-8'); 
     
    1919$t->diag('->render()'); 
    2020$w = new sfWidgetFormSelectRadio(array('choices' => array('foo' => 'bar', 'foobar' => 'foo'), 'separator' => '')); 
    21 $output = '<ul class="radio_list"><li><input name="foo" type="radio" value="foo" id="foo_foo" />&nbsp;<label for="foo_foo">bar</label></li>'. 
    22 '<li><input name="foo" type="radio" value="foobar" id="foo_foobar" checked="checked" />&nbsp;<label for="foo_foobar">foo</label></li></ul>'; 
    23 $t->is($w->render('foo', 'foobar'), $output, '->render() renders a select tag with the value selected'); 
     21$output = '<ul class="radio_list">'. 
     22'<li><input name="foo" type="radio" value="foo" id="foo_foo" />&nbsp;<label for="foo_foo">bar</label></li>'. 
     23'<li><input name="foo" type="radio" value="foobar" id="foo_foobar" checked="checked" />&nbsp;<label for="foo_foobar">foo</label></li>'. 
     24'</ul>'; 
     25$t->is($w->render('foo', 'foobar'), $output, '->render() renders a radio tag with the value checked'); 
     26 
     27//regression for ticket #3528 
     28$onChange = '<ul class="radio_list">'. 
     29'<li><input name="foo" type="radio" value="foo" id="foo_foo" onChange="alert(42)" />'. 
     30'&nbsp;<label for="foo_foo">bar</label></li>'. 
     31'<li><input name="foo" type="radio" value="foobar" id="foo_foobar" checked="checked" onChange="alert(42)" />'. 
     32'&nbsp;<label for="foo_foobar">foo</label></li>'. 
     33'</ul>'; 
     34$t->is($w->render('foo', 'foobar', array('onChange' => 'alert(42)')), $onChange, '->render() renders a radio tag using extra attributes'); 
    2435 
    2536// choices as a callable