예제 #1
0
 public function testCanSetDefaultOptionMultiselect()
 {
     $select = new Select('color', array('red' => 'Red', 'blue' => 'Blue'));
     $expected = '<select class="ui dropdown" name="color"><option value="red" selected>Red</option><option value="blue" selected>Blue</option></select>';
     $result = $select->defaultValue(array('blue', 'red'))->render();
     $this->assertEquals($expected, $result);
     $select = new Select('fruit', array('apple' => 'Granny Smith', 'berry' => 'Blueberry'));
     $expected = '<select class="ui dropdown" name="fruit"><option value="apple" selected>Granny Smith</option><option value="berry">Blueberry</option></select>';
     $result = $select->defaultValue(array('apple'))->render();
     $this->assertEquals($expected, $result);
     $select = new Select('fruit', array('apple' => 'Granny Smith', 'berry' => 'Blueberry'));
     $expected = '<select class="ui dropdown" name="fruit"><option value="apple">Granny Smith</option><option value="berry" selected>Blueberry</option></select>';
     $result = $select->select('berry')->defaultValue(array('apple', 'berry'))->render();
     $this->assertEquals($expected, $result);
     $select = new Select('fruit', array('apple' => 'Granny Smith', 'berry' => 'Blueberry'));
     $expected = '<select class="ui dropdown" name="fruit"><option value="apple">Granny Smith</option><option value="berry" selected>Blueberry</option></select>';
     $result = $select->defaultValue('apple')->select(array('berry'))->render();
     $this->assertEquals($expected, $result);
 }
예제 #2
0
 public function select($name, $options = array(), $defaultValue = null)
 {
     $select = new Select($name, $options);
     $selected = $this->getValueFor($name);
     $select->select($selected);
     $select->defaultValue($defaultValue);
     return $select;
 }