Skip to content

Welcome to Guriddo Form PHP

Introduction

Guriddo Form PHP is a server-side component built on top of open and widely used standards. It is a simple, yet powerful PHP form class, which enables you to create and validate your forms in seconds.

For best results and time saving use Guriddo Visual Form builder

Features

Bellow is the list of the most common featutres (in general)

  • Ajax Submit (via jQuery Form plugin)
  • Multilingual (field captions, default values, error messages).
  • ClientSide validation(when used HTML5)
  • Serverside side validation
  • Access rights; the same form can be used for different users/groups.
  • Can deal with hitting enter in text fields .
  • Offers some nice DOM API form element implementations and some more ready-to-use out-of-the-box special fields.
  • Can deal with include-once and onLoad javascript stuff.
  • Auto-persisting of submitted forms to database. This includes the auto-creation/update of the database table.
  • No limits: everything you can do with plain HTML can be done with this package.
  • Bootstrap 4, Bootstrap 5, jQuery UI CSS frameworks support
  • Custom Templates
  • Up to 5 types of views
  • Custom templates...

Requirements and installation

For installing the package please refer to this link

Quick Start

If only the form class is used the minimal installation includes Bootstrap 5 files, jQuery Lib , form plugin distributed with the package, and jqform CSS file. Bellow is the simple setup with comments:

Note

Before using this or any other example in the Guriddo Suito PHP, please import the northwind database and set user name and password in the provided configuration file.

<?php?>
<!DOCTYPE html>
<html>
<!-- bootstrap 5 -->
<head>
...
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-0evHe/X+R7YkIZDRvuzKMRqM+OrBnVFBL6DOitfPri4tjfHxaWutUpFmBp4vmVor" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.8.0/font/bootstrap-icons.css">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/js/bootstrap.bundle.min.js" integrity="sha384-pprn3073KE6tl6bjs2QrFaJGz5/SUsLqktiwsUTF55Jfv3qYSDhgCecCxMW52nD2" crossorigin="anonymous"></script>
<!-- jquery  -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.3/jquery.min.js" integrity="sha512-STof4xm1wgkfm7heWqFJVn58Hm3EtS31XFaagaa8VMReCXAkQnJZ+jEy8PCC/iT18dFy95WcExNHFTqLyp72eQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<!-- form plugin -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.form/4.3.0/jquery.form.min.js" integrity="sha384-qlmct0AOBiA2VPZkMY3+2WqkHtIQ9lSdAsAn5RUJD/3vA5MKDgSGcdmIv4ycVxyn" crossorigin="anonymous"></script>
<link rel="stylesheet" href="../vendor/dist/css/ui.jqform.css">

</head>
<body>
......
<div>
    <?php include "myfirstform.php";?>
</div>

.......
</body>
</html>

Save the file as formdemo.php (or any other name) and then create myfirstform.php with the following content. In this file we will describe every line of code.

<?php
ini_set("display_errors",1);
// include the vendor autoload where the Guriddo package is installed
require_once '../../../../vendor/autoload.php';
// include database credential. 
require_once 'dbconfig.php'

// we need to use Utils class to set correct the location 
// to the form file
use Guriddo\Utils\Utils;


// Create form instance with initial data
$newForm = new Guriddo\Form\Form('newForm',array('method' => 'post', 'id' => 'newForm'));
// Set url
$newForm->setUrl(Utils::fileUrl(__FILE__));
// create a frame around the form
$newForm->frame = true;
// setup the database connection
$conn = new PDO(DB_DSN, DB_USER, DB_PASSWORD);
// set it to be used into the form when data is posted
$newForm->setConnection( $conn );
// table where the data should be saved, again with the key 
$newForm->table = 'orders';
$newForm->setPrimaryKeys('OrderID');
$newForm->serialKey = true;

// Set Bootstrap Form layout 
$newForm->setView('horizontal');
$newForm->setStyling('bootstrap5');

// Add elements which names correspond to those in the table
// We can set various properties whith all possible HTML attributes
$newForm->addElement('OrderID','hidden', array('label' => 'OrderID', 'id' => 'newForm_OrderID'));
$newForm->addElement('ShipName','text', array('label' => 'Name', 'maxlength' => '40', 'style' => '', 'id' => 'newForm_ShipName'));
$newForm->addElement('ShipAddress','text', array('label' => 'Address', 'maxlength' => '60', 'style' => '', 'id' => 'newForm_ShipAddress'));
$newForm->addElement('ShipCity','text', array('label' => 'City', 'maxlength' => '15', 'size' => '20', 'id' => 'newForm_ShipCity'));
$newForm->addElement('ShipPostalCode','text', array('label' => 'PostalCode', 'maxlength' => '10', 'size' => '20', 'id' => 'newForm_ShipPostalCode'));
$newForm->addElement('ShipCountry','text', array('label' => 'Country', 'maxlength' => '15', 'size' => '20', 'id' => 'newForm_ShipCountry'));
$newForm->addElement('Freight','number', array('label' => 'Freight', 'id' => 'newForm_Freight'));
// Create a button group with submit button
$elem_12[]=$newForm->createElement('newSubmit','submit', array('value' => 'Submit'));
$newForm->addGroup("newGroup",$elem_12, array('style' => '', 'id' => 'newForm_newGroup'));
// Add ajax submit events ( optional)
$newForm->setAjaxOptions( array('iframe' => false,
'forceSync' =>false) );
// Render the form 
echo $newForm->renderForm($jqformparams);

Save the file and run the file and formdemo.php in the browser.