WPDKHTMLTagSelect::__construct PHP Method

__construct() public method

Create an instance of WPDKHTMLTagSelect class
public __construct ( array | callback $options = [], string $name = '', string $id = '' )
$options array | callback A key value pairs array with value/text or a callback function
$name string Attribute name
$id string Attribute id
    public function __construct($options = array(), $name = '', $id = '')
    {
        /* Create an WPDKHTMLTag instance. */
        parent::__construct(WPDKHTMLTagName::SELECT);
        /* Store the options for draw later. */
        $this->_options = $options;
        /* Set name. */
        if (!empty($name)) {
            $this->name = $name;
        }
        /* To default, if $name exists and $id not exists, then $id = $name. */
        if (!empty($name) && empty($id)) {
            /* Check if field is an array. */
            if ('[]' == substr($name, -2)) {
                /* Sanitize id. */
                $this->id = substr($name, 0, strlen($name) - 2);
            } else {
                $this->id = $name;
            }
        } elseif (!empty($id)) {
            $this->id = $id;
        }
        /* Setting. */
        $this->open = '<select';
        $this->close = '</select>';
        $this->attributes = array('autofocus', 'disabled', 'form', 'multiple', 'name', 'size');
    }