OctoberCMS plugin form database relationships
Ad
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.
Example:
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?
Ad
Answer
Ad
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()
{
}
Ad
source: stackoverflow.com
Related Questions
Ad
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → October CMS - Conditionally Load a Different Page
- → How to disable assets combining on development in OctoberCMS
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → OctoberCms component: How to display all ID(items) instead of sorting only one ID?
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?
Ad