Redaxscript\Html\Form::select PHP Method

select() public method

append the select
Since: 2.6.0
public select ( array $optionArray = [], array $attributeArray = [] ) : Form
$optionArray array options of the select
$attributeArray array attributes of the select
return Form
    public function select($optionArray = [], $attributeArray = [])
    {
        if (is_array($attributeArray)) {
            $attributeArray = array_merge($this->_attributeArray['select'], $attributeArray);
        } else {
            $attributeArray = $this->_attributeArray['select'];
        }
        $selectElement = new Element();
        $selectElement->init('select', $attributeArray)->html($this->_createOption($optionArray, $attributeArray['value']))->val(null);
        $this->append($selectElement);
        return $this;
    }

Usage Example

 /**
  * testSelect
  *
  * @param array $optionArray
  * @param array $attributeArray
  * @param array $expect
  *
  * @dataProvider providerSelect
  *
  * @since 2.6.0
  */
 public function testSelect($optionArray = array(), $attributeArray = array(), $expect = array())
 {
     /* setup */
     $form = new Html\Form($this->_registry, $this->_language);
     $form->init();
     $form->select($optionArray, $attributeArray);
     /* actual */
     $actual = $form;
     /* compare */
     $this->assertEquals($expect, $actual);
 }