PHP code example of gerson22 / formap
1. Go to this page and download the library: Download gerson22/formap 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/ */
gerson22 / formap example snippets
$input = "<input type=\":type\" id=':name' name=':name' class=\"form-control\" placeholder=\":alias\">";
define('LAYOUT_INPUT',$input);//text,number,date,color etc
$select = "<selectname=':name' id=':name'>
<option val='NULL' selected>Elige una opción</option>
</select>";
define('LAYOUT_SELECT',$select);
$file = "<input type='file' name=':name'>";
define('LAYOUT_FILE',$file);
re 'vendor/autoload.php';
use Formap\Form;
$tableName = 'users';
/*
* @params String $tableName
*/
$frm = new Form($tableName);
/*
* @return String
*/
$frm->all()->toHTML();
namespace App\Http\Controllers;
use App\Http\Requests;
use Illuminate\Http\Request;
use Formap\Form;
class UserController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}
/**
* Show the application dashboard.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$form = new Form('users');
$except = [
['name' => 'created_at'],
['name' => 'updated_at'],
['name' => 'activo']
];
return view('users',['form'=>$form->except($except)->toHTML()]);
}
}
/*
* @return Formap\Form
*/
$frm->setId("frmUsers")
/*
* @return Formap\Form
*/
$frm->setMethod("POST")
/*
* @return Formap\Form
*/
$frm->setAction("/action.php")
/*
* @param Array
* @return Formap\Form
* 0.3.0
*/
$frm->only(
array(
['name' => 'cantidad', 'as' => 'Cantidad'],
['name' => 'producto_id', 'as' => 'Producto']
));
** 1.0.0
$frm->only(
['name' => 'cantidad', 'as' => 'Cantidad'],
['name' => 'producto_id', 'as' => 'Producto']
);
/*
* @param Array
* @return Formap\Form
* 0.3.0
*/
$frm->except(
['name' => 'producto_id']
);
* 1.0.0
$frm->except(['name' => 'producto_id']);
/*
* @return Formap\Form
*/
$frm->all();
/*
* @param Array
* @return Formap\Form
* 0.3.0
*/
$frm->add(array(
['name'=>'email','as' => 'Correo electronico', 'icon' => 'envelope'],
['name'=>'password_confirmation','as' => 'Repetir contraseña', 'type' => 'password' , 'icon' => 'lock']
));
* 1.0.0
$frm->add(
['name'=>'email','as' => 'Correo electronico', 'icon' => 'envelope'],
['name'=>'password_confirmation','as' => 'Repetir contraseña', 'type' => 'password' , 'icon' => 'lock']
);
/*
* @return String
*/
$frm->all()->toHtml();