1. Go to this page and download the library: Download andersondanilo/modelform 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/ */
andersondanilo / modelform example snippets
// SimpleForm.php
use ModelForm\Form;
use ModelForm\Fields\CharField;
use ModelForm\Fields\IntegerField;
class SimpleForm extends Form
{
public function makeFields()
{
$this->name = new CharField(['label' => 'Name']);
$this->age = new IntegerField(['label' => 'Age']);
}
}
$simpleForm = new SimpleForm(['data' => Input::old() ?: Input::all()]);
use ModelForm\Form;
use ModelForm\Fields\CharField;
use ModelForm\Fields\IntegerField;
class SimpleForm extends Form
{
public function makeFields()
{
$this->name = new CharField(['label' => 'Name']);
$this->age = new IntegerField(['label' => 'Age']);
}
public function makeModel()
{
return new MyModel();
}
public function makeValidator($data)
{
return Validator::make($data, [
'name' => '