protected function getValueAndTextFromField(Crawler $nodes)
    {
        if ($nodes->filter('textarea')->count()) {
            return (new TextareaFormField($nodes->filter('textarea')->getNode(0)))->getValue();
        }

        $input = $nodes->filter('input');
        if ($input->count()) {
            return $this->getInputValue($input);
        }

        if ($nodes->filter('select')->count()) {
            $options = $nodes->filter('option[selected]');
            $values = [];

            foreach ($options as $option) {
                $values[] = $option->getAttribute('value');
                $values[] = $option->textContent;
                $values[] = trim($option->textContent);
            }

            return $values;
        }

        $this->fail("Element $nodes is not a form field or does not contain a form field");
    }
protected function getValueAndTextFromField(Crawler $nodes)
    {
        if ($nodes->filter('textarea')->count()) {
            return (new TextareaFormField($nodes->filter('textarea')->getNode(0)))->getValue();
        }

        $input = $nodes->filter('input');
        if ($input->count()) {
            return $this->getInputValue($input);
        }

        if ($nodes->filter('select')->count()) {
            $options = $nodes->filter('option[selected]');
            $values = [];

            foreach ($options as $option) {
                $values[] = $option->getAttribute('value');
                $values[] = $option->textContent;
                $values[] = trim($option->textContent);
            }

            return $values;
        }

        $this->fail("Element $nodes is not a form field or does not contain a form field");
    }
protected function getValueAndTextFromField ( Crawler $ nodes ) { if ( $ nodes -> filter ( 'textarea' ) -> count ( ) ) { return ( new TextareaFormField ( $ nodes -> filter ( 'textarea' ) -> getNode ( 0 ) ) ) -> getValue ( ) ; } $ input = $ nodes -> filter ( 'input' ) ; if ( $ input -> count ( ) ) { return $ this -> getInputValue ( $ input ) ; } if ( $ nodes -> filter ( 'select' ) -> count ( ) ) { $ options = $ nodes -> filter ( 'option[selected]' ) ; $ values = [ ] ; foreach ( $ options as $ option ) { $ values [ ] = $ option -> getAttribute ( 'value' ) ; $ values [ ] = $ option -> textContent ; $ values [ ] = trim ( $ option -> textContent ) ; } return $ values ; } $ this -> fail ( "Element $nodes is not a form field or does not contain a form field" ) ; }
Get the values of a set of fields and also the texts of selected options.

@param Crawler $nodes
@return array|mixed|string
Get the values of a set of fields and also the texts of selected options .