PHP Classes

File: testapp/form.php

Recommend this page to a friend!
  Classes of Ar Gabid   Universal PHP Data Grid   testapp/form.php   Download  
File: testapp/form.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Universal PHP Data Grid
Display and process data to edit database records
Author: By
Last change: Update of testapp/form.php
Date: 4 years ago
Size: 2,388 bytes
 

Contents

Class file image Download
<?php
/**
 * @author GD Lab <dev.gdgrid@gmail.com>
 */

use gdgrid\gd\GridForm;
use
gdgrid\gd\GridDataProvider;
use
gdgrid\gd\GridData;

?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>App Grid</title>

    <script src="https://code.jquery.com/jquery-3.3.1.min.js"
            integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>

    <!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"
          integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

    <!-- Optional theme -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css"
          integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">

    <!-- Latest compiled and minified JavaScript -->
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"
            integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"
            crossorigin="anonymous"></script>

</head>
<body>
<div class="container">
    <h1>Add Hero</h1>

    <?php

    $t
= microtime(true);

   
$dataProvider = (new GridDataProvider($provider))
        ->
setDataProvider((new GridData)
            ->
setPdo(DB::capsule()->getConnection()->getPdo())
            ->
setTable('users')
            ->
setLocale('en'))
        ->
fetchData()
        ->
mergeData([
           
'safeFields' => [
               
'id',
            ],
           
'inputOptions' => [
               
'gender' => ['Female', 'Male']
            ],
           
'inputErrors' => $provider->getErrors(),
        ]);

   
$form = (new GridForm($dataProvider))->loadInputs();

   
$form->setForm(['action' => '/' . ROUTE . '/' . ($provider->id ?? null)]);

   
$form->setRequired($dataProvider->requiredFields());

   
$form->setRow('_submit_', '<button type="submit" class="btn btn-success">Save</button>');

    echo
$form->render();

   
?>

    <br><br>

    <?php
   
echo '<small>Form generation time: <b>' . (microtime(true) - $t) . '</b> sec</small><br>';
    echo
'<small>Page generation time: <b>' . (microtime(true) - APP_START) . '</b> sec</small>';
   
?>

</div>
</body>
</html>