public function generate()
    {
        $form = collect([]);

        // Loop all the the fields in the schema
        foreach ($this->schema->all() as $name => $input) {

            // Skip the one that don't have a `form` definition
            if (isset($input['form'])) {

                // Get the value from the data
                $value = isset($this->data[$name]) ? $this->data[$name] : null;

                // Add the namespace to the name if it's defined
                $name = ($this->formNamespace != '') ? $this->formNamespace.'['.$name.']' : $name;

                // Get the element class and make sure it exist
                $type = (isset($input['form']['type'])) ? $input['form']['type'] : 'text';
                $type = 'UserFrosting\\Sprinkle\\FormGenerator\\Element\\'.Str::studly($type);

                // If class doesn't esist, default to Text element
                if (!class_exists($type)) {
                    $type = 'UserFrosting\\Sprinkle\\FormGenerator\\Element\\Text';
                }

                // Create a new instance
                $element = new $type($name, $input['form'], $value);

                // Push data to `$form`
                $form->put($name, $element->parse());
            }
        }

        return $form->toArray();
    }
public function generate()
    {
        $form = collect([]);

        // Loop all the the fields in the schema
        foreach ($this->schema->all() as $name => $input) {

            // Skip the one that don't have a `form` definition
            if (isset($input['form'])) {

                // Get the value from the data
                $value = isset($this->data[$name]) ? $this->data[$name] : null;

                // Add the namespace to the name if it's defined
                $name = ($this->formNamespace != '') ? $this->formNamespace.'['.$name.']' : $name;

                // Get the element class and make sure it exist
                $type = (isset($input['form']['type'])) ? $input['form']['type'] : 'text';
                $type = 'UserFrosting\\Sprinkle\\FormGenerator\\Element\\'.Str::studly($type);

                // If class doesn't esist, default to Text element
                if (!class_exists($type)) {
                    $type = 'UserFrosting\\Sprinkle\\FormGenerator\\Element\\Text';
                }

                // Create a new instance
                $element = new $type($name, $input['form'], $value);

                // Push data to `$form`
                $form->put($name, $element->parse());
            }
        }

        return $form->toArray();
    }
public function generate ( ) { $ form = collect ( [ ] ) ; // Loop all the the fields in the schema foreach ( $ this -> schema -> all ( ) as $ name => $ input ) { // Skip the one that don't have a `form` definition if ( isset ( $ input [ 'form' ] ) ) { // Get the value from the data $ value = isset ( $ this -> data [ $ name ] ) ? $ this -> data [ $ name ] : null ; // Add the namespace to the name if it's defined $ name = ( $ this -> formNamespace != '' ) ? $ this -> formNamespace . '[' . $ name . ']' : $ name ; // Get the element class and make sure it exist $ type = ( isset ( $ input [ 'form' ] [ 'type' ] ) ) ? $ input [ 'form' ] [ 'type' ] : 'text' ; $ type = 'UserFrosting\\Sprinkle\\FormGenerator\\Element\\' . Str :: studly ( $ type ) ; // If class doesn't esist, default to Text element if ( ! class_exists ( $ type ) ) { $ type = 'UserFrosting\\Sprinkle\\FormGenerator\\Element\\Text' ; } // Create a new instance $ element = new $ type ( $ name , $ input [ 'form' ] , $ value ) ; // Push data to `$form` $ form -> put ( $ name , $ element -> parse ( ) ) ; } } return $ form -> toArray ( ) ; }
Generate an array contining all nececerry value to generate a form
with Twig.

@return array The form fields data
Generate an array contining all nececerry value to generate a form with Twig .