-
I have a problem in relation behavior in backend controller
folder/models folder/models/category folder/models/product folder/controllers folder/controllers/category |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Syntax error in folder/models/Product.php public $table = 'as7_relationtest_product'; '; // table fields : id,name,category_id
public $belongsTo = [ 'category' => [Category::class] ]; Twice Corrected: public $table = 'as7_relationtest_product'; // table fields : id,name,category_id
public $belongsTo = [
'category' => [Category::class]
]; In folder/controllers/Category.php values in use Backend\Classes\Controller;
use BackendMenu;
class Category extends Controller
{
public $implement = [
\Backend\Behaviors\FormController::class,
\Backend\Behaviors\ListController::class,
\Backend\Behaviors\RelationController::class,
];
public $listConfig = 'config_list.yaml';
public $formConfig = 'config_form.yaml';
public $relationConfig = 'config_relation.yaml';
public function __construct()
{
parent::__construct();
BackendMenu::setContext('As7.Relationtest', 'main-menu-item');
}
} |
Beta Was this translation helpful? Give feedback.
Syntax error in folder/models/Product.php
Twice
'; ';
int_product'; '; // table
Corrected:
In folder/controllers/Category.php values in
$implement