src/CrudGenerator.php
public static function edit($config, $id = null, $simple = false, $registro = null) {
        //$config = CrudGenerator::translateConfig($config);
        $modelo = strtolower(class_basename($config["modelo"]));
        $config = CrudGenerator::loadTodosFromConfig($config);

        if ($registro == null) {
            $modeloM = ucfirst($config['modelo']);
            if ($id == null) {
                $registro = $modeloM::first();
            } elseif (is_object($id)) {
                $registro = $id;
                $id = $registro->getKey();
            } else {
                $registro = $modeloM::find($id);
            }
        }
        if (!CrudGenerator::checkPermission($config, $registro->getKey())) {
            return View::make('sirgrimorum::crudgen.error', ['message' => trans('crudgenerator::admin.messages.permission')]);
        }
        if ($config['url'] == "Sirgrimorum_CrudAdministrator") {
            $config['url'] = route("sirgrimorum_modelo::update", ["modelo" => $modelo, "registro" => $registro->id]);
            if (\Lang::has('crudgenerator::' . $modelo . '.labels.edit')) {
                $config['botones'] = trans("crudgenerator::$modelo.labels.edit");
            } else {
                $config['botones'] = trans("crudgenerator::admin.layout.editar");
            }
        }
        if (!$simple) {
            $js_section = config("sirgrimorum.crudgenerator.js_section");
            $css_section = config("sirgrimorum.crudgenerator.css_section");
        } else {
            $js_section = "";
            $css_section = "";
        }
        $view = View::make('sirgrimorum::crudgen.edit', [
                    'config' => $config,
                    'registro' => $registro,
                    'tieneHtml' => CrudGenerator::hasTipo($config, ['html','article']),
                    'tieneDate' => CrudGenerator::hasTipo($config, ['date', 'datetime', 'time']),
                    'tieneSlider' => CrudGenerator::hasTipo($config, 'slider'),
                    'tieneSelect' => CrudGenerator::hasTipo($config, ['select', 'relationship', 'relationships']),
                    'tieneSearch' => CrudGenerator::hasTipo($config, [ 'relationshipssel']),
                    'tieneFile' => CrudGenerator::hasTipo($config, [ 'file', 'files']),
                    'tieneJson' => CrudGenerator::hasTipo($config, [ 'json']),
                    'js_section' => $js_section,
                    'css_section' => $css_section,
                    'modelo' => $modelo
        ]);
        return $view->render();
    }
public static function edit($config, $id = null, $simple = false, $registro = null) {
        //$config = CrudGenerator::translateConfig($config);
        $modelo = strtolower(class_basename($config["modelo"]));
        $config = CrudGenerator::loadTodosFromConfig($config);

        if ($registro == null) {
            $modeloM = ucfirst($config['modelo']);
            if ($id == null) {
                $registro = $modeloM::first();
            } elseif (is_object($id)) {
                $registro = $id;
                $id = $registro->getKey();
            } else {
                $registro = $modeloM::find($id);
            }
        }
        if (!CrudGenerator::checkPermission($config, $registro->getKey())) {
            return View::make('sirgrimorum::crudgen.error', ['message' => trans('crudgenerator::admin.messages.permission')]);
        }
        if ($config['url'] == "Sirgrimorum_CrudAdministrator") {
            $config['url'] = route("sirgrimorum_modelo::update", ["modelo" => $modelo, "registro" => $registro->id]);
            if (\Lang::has('crudgenerator::' . $modelo . '.labels.edit')) {
                $config['botones'] = trans("crudgenerator::$modelo.labels.edit");
            } else {
                $config['botones'] = trans("crudgenerator::admin.layout.editar");
            }
        }
        if (!$simple) {
            $js_section = config("sirgrimorum.crudgenerator.js_section");
            $css_section = config("sirgrimorum.crudgenerator.css_section");
        } else {
            $js_section = "";
            $css_section = "";
        }
        $view = View::make('sirgrimorum::crudgen.edit', [
                    'config' => $config,
                    'registro' => $registro,
                    'tieneHtml' => CrudGenerator::hasTipo($config, ['html','article']),
                    'tieneDate' => CrudGenerator::hasTipo($config, ['date', 'datetime', 'time']),
                    'tieneSlider' => CrudGenerator::hasTipo($config, 'slider'),
                    'tieneSelect' => CrudGenerator::hasTipo($config, ['select', 'relationship', 'relationships']),
                    'tieneSearch' => CrudGenerator::hasTipo($config, [ 'relationshipssel']),
                    'tieneFile' => CrudGenerator::hasTipo($config, [ 'file', 'files']),
                    'tieneJson' => CrudGenerator::hasTipo($config, [ 'json']),
                    'js_section' => $js_section,
                    'css_section' => $css_section,
                    'modelo' => $modelo
        ]);
        return $view->render();
    }
public static function edit ( $ config , $ id = null , $ simple = false , $ registro = null ) { //$config = CrudGenerator::translateConfig($config);
 $ modelo = strtolower ( class_basename ( $ config [ "modelo" ] ) ) ; $ config = CrudGenerator :: loadTodosFromConfig ( $ config ) ; if ( $ registro == null ) { $ modeloM = ucfirst ( $ config [ 'modelo' ] ) ; if ( $ id == null ) { $ registro = $ modeloM :: first ( ) ; } elseif ( is_object ( $ id ) ) { $ registro = $ id ; $ id = $ registro -> getKey ( ) ; } else { $ registro = $ modeloM :: find ( $ id ) ; } } if ( ! CrudGenerator :: checkPermission ( $ config , $ registro -> getKey ( ) ) ) { return View :: make ( 'sirgrimorum::crudgen.error' , [ 'message' => trans ( 'crudgenerator::admin.messages.permission' ) ] ) ; } if ( $ config [ 'url' ] == "Sirgrimorum_CrudAdministrator" ) { $ config [ 'url' ] = route ( "sirgrimorum_modelo::update" , [ "modelo" => $ modelo , "registro" => $ registro -> id ] ) ; if ( \ Lang :: has ( 'crudgenerator::' . $ modelo . '.labels.edit' ) ) { $ config [ 'botones' ] = trans ( "crudgenerator::$modelo.labels.edit" ) ; } else { $ config [ 'botones' ] = trans ( "crudgenerator::admin.layout.editar" ) ; } } if ( ! $ simple ) { $ js_section = config ( "sirgrimorum.crudgenerator.js_section" ) ; $ css_section = config ( "sirgrimorum.crudgenerator.css_section" ) ; } else { $ js_section = "" ; $ css_section = "" ; } $ view = View :: make ( 'sirgrimorum::crudgen.edit' , [ 'config' => $ config , 'registro' => $ registro , 'tieneHtml' => CrudGenerator :: hasTipo ( $ config , [ 'html' , 'article' ] ) , 'tieneDate' => CrudGenerator :: hasTipo ( $ config , [ 'date' , 'datetime' , 'time' ] ) , 'tieneSlider' => CrudGenerator :: hasTipo ( $ config , 'slider' ) , 'tieneSelect' => CrudGenerator :: hasTipo ( $ config , [ 'select' , 'relationship' , 'relationships' ] ) , 'tieneSearch' => CrudGenerator :: hasTipo ( $ config , [ 'relationshipssel' ] ) , 'tieneFile' => CrudGenerator :: hasTipo ( $ config , [ 'file' , 'files' ] ) , 'tieneJson' => CrudGenerator :: hasTipo ( $ config , [ 'json' ] ) , 'js_section' => $ js_section , 'css_section' => $ css_section , 'modelo' => $ modelo ] ) ; return $ view -> render ( ) ; }
Generate de edit view of a model
@param array $config Configuration array
@param integer $id Key of the object
@param boolean $simple Optional True for a simple view (just the form)
@param Model $registro Optional The object
@return HTML Edit form
Generate de edit view of a model