OctoberCMS plugin form database relationships

- 1 answer


I am making a plugin on October CMS builder. Created couple db tables, models and forms in backend. Now trying to add form element (checkboxes) and want to make checkbox values to be taken from other table.


Table 1: categories
Model: Categories (relates to table categories)
Columns: id(INT, AI), name(VARCHAR), types(TEXT)

Table 2: types
Model: Types (relates to table types)
Columns: id(INT, AI), type(INT)

So in category creation form i want to assign types. For example:

Category name: News
Types: 1, 3, 7 (from table: types column: type)

How do i make this work?




Ok i found it. Lookep up in Rainlab plugin for relations and options.

In my Category model i have added a function to fetch required data from other table and it worked.

public function getTypesOptions()

source: stackoverflow.com