Download and install
- install: copy it in your php server folder
Setting the mysql connection
Open the file "masterdata/_mysql.php and set the connection parameter to your mysql-server: server, username, password and database.
SQL for item example
Masterdata/sql contains the sql script to create the example table: k8components.
Open the file 'masterdata_form.php' in your root path with an editor. The file looks like this:
In the head and body the links to tabbulator, jsonform, bootstrap and masterdata are set.
The Master data form is displayed in the HTML element '#masterdata1'.
The function displayMasterData(selector,url) in the script loads the datadefintion with the "datadefID=1". "ProcessData.php" manages all requests and gives back the json datastructure of the datadefinition. After getting the datadefinition the following function is called:
and the master data form is displayed in '#masterdata1'.
The datadefinition is my test definition. The data is stored in the session and is running without mysql. For all other definitions, you have to connect to your mysql server.
The datadefinition is the items definition. The data is stored in the database. On this definition we will have a look for the changes and improvements.
Getting the basic datadefinition of your table
Requirement: primary key of the table
- the Primary key has to consist of an single field
- type: int
The primary key is a hidden field in the master data form. It can not be changed!
Here on my datadefinition page you can input the datadefID or the table. The important parts of the datadefinition is displayed.
In your installation you can start the "get_datadefinition.php" in your Browser. Add the tablename in your url like this:
Copy your datadefinition in masterdata/datadefintions.php. Choose an ID like . Modify it until you are satisfied with the appearance of the master data form. You will get an example of the changes for the table 'k8components' in the chapter. Details for the configuration of the listing are on the tabulator page. Details for the form are explained in jsonform.
Improving the datadefinition: k8compponents
changes in the datadefinition with green background
vertical / horizontal form
the formtype and the formclass are changend in 'jsonform_conf' (both need to be defined):
- 0, form-inline
- 1, form-vertical
- 2, form-horizontal, default-setting in masterdata.js
by using horizontal form the following properties have to be set:
- labelHtmlClass=label-control col-sm-3
- add "label-left", if wished
form with 2 or more columns
If you like to have 2 blocks, you have to use the "type":"section" or "fieldset" in the "form"-area, example with "section":
form definition with 2 blocks
CSS, Changing the appearance
Choose the right CSS file for the area which you like to change:
- masterdata for headline and footline
- tabulator for the listing
- jsonform, bootstrap for the form
Take the file names please out of our code example at the top!
Example of a datadefinition
Attention Json, please regard to enclose your collection keys in quotes. So you can easily check your json datastructure in jsonlint!
Signification of the properties:
- name: displayed in the form headline
- table: if columns is not defined, the table structure is read and stored in the columns array
- key: Primary key field of the thable
- objectclass: name of the data access class
- requiredfile: php file of the objectclass
- masterdata: url for the data access
- columns: array of the table fields. The "column" part of the definition is important for the data access class. Only this fields are saved to the database
- tabulator: definition for the recordset list in the header
please change the listing here!
- jsonform: definition for the fields in the form
please change the form here!
- jsonform_conf: configuration of vertical and horizontal form
tabulator, used properties:
- "layout"=>"fitColumns", to spread the columns along the whole list width
- headerfilter (true ,false)
- headerSort (default:true, false)
- width (in px)
- align (left|center|right)
- formatter: money, date
- formatterparams, http://tabulator.info/docs/4.4/format#format-builtin)
- date (http://tabulator.info/docs/4.1/format)
jsonform, used schema properties:
- type (string, number, integer, boolean, array, object)
- step ("0.01" allows 2 decimal places)
- enum (for select,['value1','value2'])