Skip to content

How To Implement An One To Many Relationship To Form (E.g : Product <- Category) ​

Products Table - products ​

Field NameDescription
idint(PK)
created_attimestamp
namevarchar(255)
descriptiontext
categories_idint(11)

Categories Table - categories ​

Field NameDescription
idint(PK)
created_attimestamp
namevarchar(255)

Form ​

php
$this->form[] = ['label'=>'Name','name'=>'name','type'=>'text'];
$this->form[] = ['label'=>'Description','name'=>'description','type'=>'textarea'];
$this->form[] = ['label'=>'Category','name'=>'categories_id','type'=>'select','datatable'=>'categories,name'];

Column ​

php
$this->col[] = ['label'=>'Name','name'=>'name'];
$this->col[] = ['label'=>'Description','name'=>'description'];
$this->col[] = ['label'=>'Category','name'=>'categories_id','join'=>'categories,name'];

What's Next ​

Table Of Contents ​

Released under the MIT License.