Skip to content

How To Make A Child Form (Master - Detail) ​

Table Products : products ​

Field NameData Type
idint(PK)
created_attimestamp
namevarchar(255)
pricedouble

Table Customers : customers ​

Field NameData Type
idint(PK)
created_attimestamp
namevarchar(255)

Table Master : orders ​

Field NameData Type
idint(PK)
created_attimestamp
customers_idint(11)
order_numbervarchar(25)

Table Detail : orders_detail ​

Field NameData Type
idint(PK)
created_attimestamp
orders_idint(11)
products_idint(11)
pricedouble
discountdouble
qtyint(10)
subtotaldouble

Code Example ​

php
$columns[] = ['label'=>'Product','name'=>'products_id','type'=>'datamodal','datamodal_table'=>'products','datamodal_columns'=>'name,price','datamodal_select_to'=>'price:price','datamodal_where'=>'','datamodal_size'=>'large'];
$columns[] = ['label'=>'Price','name'=>'price','type'=>'number','required'=>true];
$columns[] = ['label'=>'QTY','name'=>'qty','type'=>'number','required'=>true];
$columns[] = ['label'=>'Discount','name'=>'discount','type'=>'number','required'=>true];
$columns[] = ['label'=>'Sub Total','name'=>'subtotal','type'=>'number','formula'=>"[qty] * [price] - [discount]","readonly"=>true,'required'=>true];
$this->form[] = ['label'=>'Orders Detail','name'=>'orders_detail','type'=>'child','columns'=>$columns,'table'=>'orders_detail','foreign_key'=>'orders_id'];

image

Legend For Child Type ​

AttributeDescription
columnsFill an array like an example
tablethe relationship (detail) table
foreign_keyfk for relationship (detail) table

Child Form Type Available ​

Type NameAdditional Attribute
textmin,max
numbermin,max
textareamax
selectdatatable - e.g : 'tableName,fieldName'
radiodataenum - e.g : ['a','b','c [, ...]]
uploadupload_type - (image,file)
datamodaldatamodal_table,datamodal_columns,datamodal_select_to,datamodal_where,datamodal_size,datamodal_height,datamodal_paginate

What's Next ​

Table Of Contents ​

Released under the MIT License.