render() public method

public render ( )
Example #1
0
 public function testSelectCanBeCreatedWithIntegerKeyValueOptions()
 {
     $select = new Select('color', array('0' => 'Red', '1' => 'Blue'));
     $expected = '<select name="color"><option value="0">Red</option><option value="1">Blue</option></select>';
     $result = $select->render();
     $this->assertEquals($expected, $result);
     $select = new Select('fruit', array('1' => 'Granny Smith', '0' => 'Blueberry'));
     $expected = '<select name="fruit"><option value="1">Granny Smith</option><option value="0">Blueberry</option></select>';
     $result = $select->render();
     $this->assertEquals($expected, $result);
 }
Example #2
0
 public function testCanMixNestedAndUnnestedOptions()
 {
     $options = array('toronto' => 'Toronto', 'london' => 'London', 'Quebec' => array('montreal' => 'Montreal', 'quebec-city' => 'Quebec City'));
     $select = new Select('color', $options);
     $expected = '<select name="color"><option value="toronto">Toronto</option><option value="london">London</option><optgroup label="Quebec"><option value="montreal">Montreal</option><option value="quebec-city">Quebec City</option></optgroup></select>';
     $result = $select->render();
     $this->assertEquals($expected, $result);
 }