private function createOptionNode($value, $text)
    {
        $option = new NodeElement();
        $option->openTag('option')
               ->addAttribute('value', $value);

        // Mark as selected on demand
        if ($this->isActiveNode($value)) {
            $option->addProperty('selected');
        }

        // If callback is provided, then use it to build attributes
        if ($this->optionVisitor instanceof Closure) {
            $result = call_user_func($this->optionVisitor, $value, $text);

            // Visitor must return an array containing these keys
            if (is_array($result)) {
                $option->addAttributes($result);
            } else {
                // Incorrect returned value
                throw new UnexpectedValueException(
                    sprintf('The visitor must return associative array with attribute names and their corresponding values. Received - "%s"', gettype($result))
                );
            }
        }

        $option->finalize()
               ->setText($text)
               ->closeTag();

        return $option;
    }
private function createOptionNode($value, $text)
    {
        $option = new NodeElement();
        $option->openTag('option')
               ->addAttribute('value', $value);

        // Mark as selected on demand
        if ($this->isActiveNode($value)) {
            $option->addProperty('selected');
        }

        // If callback is provided, then use it to build attributes
        if ($this->optionVisitor instanceof Closure) {
            $result = call_user_func($this->optionVisitor, $value, $text);

            // Visitor must return an array containing these keys
            if (is_array($result)) {
                $option->addAttributes($result);
            } else {
                // Incorrect returned value
                throw new UnexpectedValueException(
                    sprintf('The visitor must return associative array with attribute names and their corresponding values. Received - "%s"', gettype($result))
                );
            }
        }

        $option->finalize()
               ->setText($text)
               ->closeTag();

        return $option;
    }
private function createOptionNode ( $ value , $ text ) { $ option = new NodeElement ( ) ; $ option -> openTag ( 'option' ) -> addAttribute ( 'value' , $ value ) ; // Mark as selected on demand if ( $ this -> isActiveNode ( $ value ) ) { $ option -> addProperty ( 'selected' ) ; } // If callback is provided, then use it to build attributes if ( $ this -> optionVisitor instanceof Closure ) { $ result = call_user_func ( $ this -> optionVisitor , $ value , $ text ) ; // Visitor must return an array containing these keys if ( is_array ( $ result ) ) { $ option -> addAttributes ( $ result ) ; } else { // Incorrect returned value throw new UnexpectedValueException ( sprintf ( 'The visitor must return associative array with attribute names and their corresponding values. Received - "%s"' , gettype ( $ result ) ) ) ; } } $ option -> finalize ( ) -> setText ( $ text ) -> closeTag ( ) ; return $ option ; }
Creates option node

@param string $value
@param string $text
@throws \UnexpectedValueException If visitor is not returning an associative array
@return \Krystal\Form\NodeElement
Creates option node