src/Services/FormMaker.php
public function fromTable(
        $table,
        $columns = null,
        $class = null,
        $view = null,
        $reformatted = true,
        $populated = false,
        $idAndTimestamps = false
    ) {
        $formBuild = [];

        if (is_null($class)) {
            $class = config('form-maker.forms.form-class', 'form-control');
        }

        $tableColumns = $this->getTableColumns($table, true);
        if (is_null($columns)) {
            foreach ($tableColumns as $column => $value) {
                $columns[$column] = $value['type'];
            }
        }

        if (!$idAndTimestamps) {
            unset($columns['id']);
            unset($columns['created_at']);
            unset($columns['updated_at']);
            unset($columns['deleted_at']);
        }

        foreach ($columns as $column => $columnConfig) {
            if (is_numeric($column)) {
                $column = $columnConfig;
            }

            $errors = $this->getFormErrors();
            $input = $this->inputMaker->create($column, $columnConfig, $column, $class, $reformatted, $populated);
            $formBuild[] = $this->formBuilder($view, $errors, $columnConfig, $column, $input);
        }

        return $this->buildUsingColumns($formBuild, config('form-maker.form.theme'));
    }
public function fromTable(
        $table,
        $columns = null,
        $class = null,
        $view = null,
        $reformatted = true,
        $populated = false,
        $idAndTimestamps = false
    ) {
        $formBuild = [];

        if (is_null($class)) {
            $class = config('form-maker.forms.form-class', 'form-control');
        }

        $tableColumns = $this->getTableColumns($table, true);
        if (is_null($columns)) {
            foreach ($tableColumns as $column => $value) {
                $columns[$column] = $value['type'];
            }
        }

        if (!$idAndTimestamps) {
            unset($columns['id']);
            unset($columns['created_at']);
            unset($columns['updated_at']);
            unset($columns['deleted_at']);
        }

        foreach ($columns as $column => $columnConfig) {
            if (is_numeric($column)) {
                $column = $columnConfig;
            }

            $errors = $this->getFormErrors();
            $input = $this->inputMaker->create($column, $columnConfig, $column, $class, $reformatted, $populated);
            $formBuild[] = $this->formBuilder($view, $errors, $columnConfig, $column, $input);
        }

        return $this->buildUsingColumns($formBuild, config('form-maker.form.theme'));
    }
public function fromTable ( $ table , $ columns = null , $ class = null , $ view = null , $ reformatted = true , $ populated = false , $ idAndTimestamps = false ) { $ formBuild = [ ] ; if ( is_null ( $ class ) ) { $ class = config ( 'form-maker.forms.form-class' , 'form-control' ) ; } $ tableColumns = $ this -> getTableColumns ( $ table , true ) ; if ( is_null ( $ columns ) ) { foreach ( $ tableColumns as $ column => $ value ) { $ columns [ $ column ] = $ value [ 'type' ] ; } } if ( ! $ idAndTimestamps ) { unset ( $ columns [ 'id' ] ) ; unset ( $ columns [ 'created_at' ] ) ; unset ( $ columns [ 'updated_at' ] ) ; unset ( $ columns [ 'deleted_at' ] ) ; } foreach ( $ columns as $ column => $ columnConfig ) { if ( is_numeric ( $ column ) ) { $ column = $ columnConfig ; } $ errors = $ this -> getFormErrors ( ) ; $ input = $ this -> inputMaker -> create ( $ column , $ columnConfig , $ column , $ class , $ reformatted , $ populated ) ; $ formBuild [ ] = $ this -> formBuilder ( $ view , $ errors , $ columnConfig , $ column , $ input ) ; } return $ this -> buildUsingColumns ( $ formBuild , config ( 'form-maker.form.theme' ) ) ; }
Generate a form from a table.

@param string $table           Table name
@param array  $columns         Array of columns and details regarding them see config/forms.php for examples
@param string $class           Class names to be given to the inputs
@param string $view            View to use - for custom form layouts
@param bool   $reformatted     Corrects the table column names to clean words if no columns array provided
@param bool   $populated       Populates the inputs with the column names as values
@param bool   $idAndTimestamps Allows id and Timestamp columns

@return string
Generate a form from a table .