AdamWathan\Form\Elements\Select::options PHP Method

options() public method

public options ( $options )
    public function options($options)
    {
        $this->setOptions($options);
        return $this;
    }

Usage Example

Example #1
0
 public function testCanSetSelectedOption()
 {
     $select = new Select('color');
     $select->options(array('red' => 'Red', 'blue' => 'Blue'));
     $expected = '<select name="color"><option value="red">Red</option><option value="blue" selected>Blue</option></select>';
     $result = $select->select('blue')->render();
     $this->assertEquals($expected, $result);
     $select = new Select('fruit');
     $select->options(array('apple' => 'Granny Smith', 'berry' => 'Blueberry'));
     $expected = '<select name="fruit"><option value="apple" selected>Granny Smith</option><option value="berry">Blueberry</option></select>';
     $result = $select->select('apple')->render();
     $this->assertEquals($expected, $result);
 }
All Usage Examples Of AdamWathan\Form\Elements\Select::options