private function getFieldPosition(\DOMElement $fieldNode)
    {
        $elements = $this->getCrawler()->filterXPath('//*[@name=\''.$fieldNode->getAttribute('name').'\']');

        if (count($elements) > 1) {
            // more than one element contains this name !
            // so we need to find the position of $fieldNode
            foreach ($elements as $key => $element) {
                /** @var \DOMElement $element */
                if ($element->getNodePath() === $fieldNode->getNodePath()) {
                    return $key;
                }
            }
        }

        return 0;
    }
private function getFieldPosition(\DOMElement $fieldNode)
    {
        $elements = $this->getCrawler()->filterXPath('//*[@name=\''.$fieldNode->getAttribute('name').'\']');

        if (count($elements) > 1) {
            // more than one element contains this name !
            // so we need to find the position of $fieldNode
            foreach ($elements as $key => $element) {
                /** @var \DOMElement $element */
                if ($element->getNodePath() === $fieldNode->getNodePath()) {
                    return $key;
                }
            }
        }

        return 0;
    }
private function getFieldPosition ( \ DOMElement $ fieldNode ) { $ elements = $ this -> getCrawler ( ) -> filterXPath ( '//*[@name=\'' . $ fieldNode -> getAttribute ( 'name' ) . '\']' ) ; if ( count ( $ elements ) > 1 ) { // more than one element contains this name ! // so we need to find the position of $fieldNode foreach ( $ elements as $ key => $ element ) { /** @var \DOMElement $element */ if ( $ element -> getNodePath ( ) === $ fieldNode -> getNodePath ( ) ) { return $ key ; } } } return 0 ; }
Gets the position of the field node among elements with the same name

BrowserKit uses the field name as index to find the field in its Form object.
When multiple fields have the same name (checkboxes for instance), it will return
an array of elements in the order they appear in the DOM.

@param \DOMElement $fieldNode

@return integer
Gets the position of the field node among elements with the same name