private function transpileFields()
    {
        $formElements = 'input, select, textarea, button';

        $this->findFormTag()->filter($formElements)->each(
            function (Crawler $node, $i) {

                // If it has a type attr, use as type
                if (null !== $node->attr('type')) {
                    $type = $node->attr('type');
                } else {
                    $type = $node->nodeName();
                }

                // Node name cames back with apostrophs on some servers
                $type = str_replace('\"', '', $type);
                // Create a FormField and get default attributes (name, value, validation, required)
                $field = $this->fieldFactory($type, $node);


                // complex form elements 1: select -> options
                if ($type === 'select') {
                    $options = $node->filter('option');

                    // FormField
                    $options->each(
                        function ($option) use ($field) {
                            $optionField = $this->fieldFactory('option', $option);
                            $field->addOption($optionField);
                        }
                    );
                }

                // complex form elements: handle file uploads
                if ($type === 'file') {
                    try {
                        $field->compactFiles($_FILES, $this->uploadDir);
                    } catch (NoFileUploadedException $noFileEx) {
                        // throw validation error?
                    }
                }

                // Add to all fields
                $this->fields[$field->getName()] = $field;

            }
        );

        return $this->fields;
    }
private function transpileFields()
    {
        $formElements = 'input, select, textarea, button';

        $this->findFormTag()->filter($formElements)->each(
            function (Crawler $node, $i) {

                // If it has a type attr, use as type
                if (null !== $node->attr('type')) {
                    $type = $node->attr('type');
                } else {
                    $type = $node->nodeName();
                }

                // Node name cames back with apostrophs on some servers
                $type = str_replace('\"', '', $type);
                // Create a FormField and get default attributes (name, value, validation, required)
                $field = $this->fieldFactory($type, $node);


                // complex form elements 1: select -> options
                if ($type === 'select') {
                    $options = $node->filter('option');

                    // FormField
                    $options->each(
                        function ($option) use ($field) {
                            $optionField = $this->fieldFactory('option', $option);
                            $field->addOption($optionField);
                        }
                    );
                }

                // complex form elements: handle file uploads
                if ($type === 'file') {
                    try {
                        $field->compactFiles($_FILES, $this->uploadDir);
                    } catch (NoFileUploadedException $noFileEx) {
                        // throw validation error?
                    }
                }

                // Add to all fields
                $this->fields[$field->getName()] = $field;

            }
        );

        return $this->fields;
    }
private function transpileFields ( ) { $ formElements = 'input, select, textarea, button' ; $ this -> findFormTag ( ) -> filter ( $ formElements ) -> each ( function ( Crawler $ node , $ i ) { // If it has a type attr, use as type if ( null !== $ node -> attr ( 'type' ) ) { $ type = $ node -> attr ( 'type' ) ; } else { $ type = $ node -> nodeName ( ) ; } // Node name cames back with apostrophs on some servers $ type = str_replace ( '\"' , '' , $ type ) ; // Create a FormField and get default attributes (name, value, validation, required) $ field = $ this -> fieldFactory ( $ type , $ node ) ; // complex form elements 1: select -> options if ( $ type === 'select' ) { $ options = $ node -> filter ( 'option' ) ; // FormField $ options -> each ( function ( $ option ) use ( $ field ) { $ optionField = $ this -> fieldFactory ( 'option' , $ option ) ; $ field -> addOption ( $ optionField ) ; } ) ; } // complex form elements: handle file uploads if ( $ type === 'file' ) { try { $ field -> compactFiles ( $ _FILES , $ this -> uploadDir ) ; } catch ( NoFileUploadedException $ noFileEx ) { // throw validation error? } } // Add to all fields $ this -> fields [ $ field -> getName ( ) ] = $ field ; } ) ; return $ this -> fields ; }
Find fields in markup
Find fields in markup