Bootstrap form

Generate a bootstrap form out of your table.


Configure the form with JSON to get it good looking!


The data access rights are easily configured in the backend and displayed in the master data form.


The form is connected to the MySQL table: register. By clicking on "Save" the data is stored and can be processed later.


All registrations are here:

index.php?datadefID=register&page=masterdata


Developer

Table requirement: primary key of the table

A table for master data has to fullfill the following rules:

  • the Primary key has to consist of a single field
    • INT, autoincrement
  • creatorID (by using the data access rights )
    • INT

The primary key is a hidden field in the master data form. It can not be changed!

Form on the fly

Checkout the generation of a form on the fly:

Open datadefinition as page

you can open the datadefintion as:

Create a datadefinition out of your table

The datadefinition contains details for reading, saving and displaying a recordset.

The following steps are necessary to create your own datadefinition:

  • er_register, if not exist create it with "k8examples.sql"
  • generate your datadefinition
  • folder <myproject> create a folder: register
  • save the datadefinition in your folder register with the name "register" as json file.
  • display the form in your browser:
    <domain>index.php?datadefID=register&page=form

kitsamples/register/register.json (just generated):

Changes in the datadefintion

This are the changes (moved one step to the left):

  • name: "Register your concern"
  • head_end: add the JavaScript file: register.js
  • masterdata
    • rights: look below
    • include: look to PHP
  • k8form: more
    • gender: radio
    • country: select
    • code and city put together to an inputgroup
    • email: type="email"
    • concern: select
    • facebook: active=false
    • memo: active=false
    • concern: select
    • already18: checkbox
    • status: select

Please note that by input: type checkbox and radio, the value needs to be specified in the datadefinition.

kitsamples/register/register.json (with changes):

JavaScript

The variable "settingsregister" consist the datadefinition for the frontend (no columns). It is declared and loaded by the file "index.php". Conditional changes are made and JavaScript functions are added here.

In this example 2 forms are prepared:

  • registration form
  • processing form

In the processing form are some more fields like the status, the creation date and the done date. The differences between this forms are defined in this JavaScript file. The registration form is spcecified with: page="doc_form". The specification for the form are:

  • notabulator=true: the plugin, which creates the form allows to create a list (tabulator) and a form. Here only the form is needed.
  • edittype=-1: the record is only send to the server.
  • this are the fields, which are not needed, actice=false:
    • status
    • datetimecreated
    • datetimedone
  • this are the call back functions:
    • cbBeforeSave
      • the question "Register?" is asked. With "cancel=true" the process of saving can be aborted.
    • cbAfterSave
      • This event is only triggered after an succesful saving process. An overlay with the succesful saving is displayed.

kitsamples/register/register.js

PHP

K8 Web Kit has an integrated RBAC system. Norrmally the creatorID of the logged in user is automatically added to the record. This registration form can be filled out without being logged in. So, this normal process will be overwritten in this case and the creatorID of the superuser is added.

The superuser has the role 2. The user ID is saved in "$creatorID", The fields from the form are in the "$this->postfield" array. So the field array "$this->postfield" is add with the creatorID of the superuser."

kitsamples/register/register_validate.php:

CSS

There are 2 css files in K8 Web Kit:

  • css/example.css
    please use this to define your CSS
  • masterdata/css/masterdata.css
    here are the CSS classes for the elements. If you want to overwrite some rules, do it in exampls.css or make a copy of it and redirect the declaration in _head.js.

The class structure of the import form is like this:

  • masterdata
    • headline
    • maindata
      • form-wrapper
        • masterdata-form
    • footline