mr.incredible
mr.incredible

Reputation: 4185

October cms checkbox list secondary description error

I have products and categories tables and product and category models.

As it is written in the documentation:

1) I have added a few lines to "plugins/author/plugin_name/models/product/fileds.yaml" file.

categories:
   label: Categories
   type: dropdown
   options: listCategories

2) I also have modified "plugins/author/plugin_name/models/Product.php" file.

public function listCategories()
   {
      $cats = \Db::table('author_plugin_name_categories')->lists('name');
      return $cats;
   }

And after that it shows list of categories on my product creation/update page.

Furthermore, I found out that dropdown type supports secondary description, so I can return associative array in the "listCategories" function. This is a great fiture. Unfortunately it works with dropdown type only.

So following problem appeared. I want to apply secondary description to checkbox list type of field or to tag list widget. Despite of the fact that checkbox list supports secondary description, an error occurs when I'm trying to apply secondary description. enter image description here

May be someone can help me to fix it? I want to use secondary description with checkbox list or with tag list widget so I can display list of cats in my product item and save only their ids to products table.

Upvotes: 0

Views: 542

Answers (1)

dragontree
dragontree

Reputation: 1799

In order to save multiple values, you need to set the model attribute as jsonable in the model file:

protected $jsonable = ['categories'];

Upvotes: 1

Related Questions