Development

Changeset 8906

You must first sign up to be able to contribute.

Changeset 8906

Show
Ignore:
Timestamp:
05/10/08 23:24:28 (3 months ago)
Author:
fabien
Message:

fixed HTML attributes for select tags

Files:

Legend:

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

    r5952 r8906  
    5959  } 
    6060 
     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   */ 
    6169  protected function getOptionsForSelect($value, $choices) 
    6270  { 
     71    $mainAttributes = $this->attributes; 
     72    $this->attributes = array(); 
     73 
    6374    $options = array(); 
    6475    foreach ($choices as $key => $option) 
     
    8091    } 
    8192 
     93    $this->attributes = $mainAttributes; 
     94 
    8295    return $options; 
    8396  } 
  • branches/1.1/test/unit/widget/sfWidgetFormSelectTest.php

    r6197 r8906  
    1111require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
    1212 
    13 $t = new lime_test(10, new lime_output_color()); 
     13$t = new lime_test(14, new lime_output_color()); 
    1414 
    1515$dom = new DomDocument('1.0', 'utf-8'); 
     
    6868$css = new sfDomCssSelector($dom); 
    6969$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');