1. Go to this page and download the library: Download kregel/formmodel library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
protected function getNewModel($model_name, FormModel $form)
{
/*
* We need to grab the model from the config and select one entry for
* that model from within the database.
*/
$model = $this->findModel($model_name);
/*
* Here we generate the form to update the model using the kregel/formmodel
* package
*/
$form_info = $form->using(config('kregel.formmodel.using.framework'))
->withModel($model)
->submitTo(route('warden::api.create-model'))
->form([
'method' => 'post',
'enctype' =>'multipart/form-data'
]);
return view('warden::view-model')
->with('form', $form_info)
->with('model_name', $model_name);
}
namespace App\FormModel\Frameworks;
use Kregel\FormModel\Interfaces\FrameworkInputs;
use Kregel\FormModel\Interfaces\FrameworkInterface;
class MyFramework extends FrameworkInputs implements FrameworkInterface
{
// The only method that you NEED is the form function
public function form(Array $options = []){
// Do Stuff (build the form)
$method = empty($options['method']) ? $options['method'] : '';
if (in_array(strtolower($method), ['get', 'post'])) {
$real_method = $method;
} else {
$real_method = 'POST';
}
$options['method'] = $real_method;
$options['action'] = $this->location;
return '<form ' . $this->attributes($options) . '>' .
// Pass the method through so the form knows how to handle it's self (with laravel)
$this->method($method) .
// Check and fill the csrf token if it's configured for it.
$this->csrf() .
$this->buildForm() .
$this->submit([]) .
'</form>';
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.