I could reproduce the error with the example in the online documentacion:
https://www.grocerycrud.com/enterprise/api-and-function-list/set-dependent-relation/
I replaced the table cities with a view of the table of itself v_view
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v_cities` AS select `cities`.`id` AS `id`,`cities`.`name` AS `name`,`cities`.`country` AS `country` from `cities` where 1 ;
The code now looks like this
public function relation()
{
$crud = $this->_getGroceryCrudEnterprise();
$crud->setTable('customers_db');
$crud->setSubject('Customer', 'Customers');
$crud->displayAs('continent_id', 'Continent');
$crud->displayAs('country_id', 'Country');
$crud->displayAs('city_id', 'City');
$crud->setRelation('continent_id','continents','name');
$crud->setRelation('country_id','countries','name');
$crud->setPrimaryKey('id', 'v_cities');
$crud->setRelation('city_id','v_cities','name');
$crud->setDependentRelation('country_id','continent_id','continent_code');
$crud->setDependentRelation('city_id','country_id','country');
$output = $crud->render();
$this->_example_output($output);
}
The error:
A PHP Error was encountered
Severity: Notice
Message: Undefined index:
Filename: Core/Model.php
Line Number: 271
Backtrace:
File: C:\xampp2\htdocs\grocery-crud-test\application\libraries\GroceryCrudEnterprise\grocerycrud\enterprise\src\GroceryCrud\Core\Model.php
Line: 271
Function: _error_handler
File: C:\xampp2\htdocs\grocery-crud-test\application\libraries\GroceryCrudEnterprise\grocerycrud\enterprise\src\GroceryCrud\Core\State\StateAbstract.php
Line: 1073
Function: getRelationData
File: C:\xampp2\htdocs\grocery-crud-test\application\libraries\GroceryCrudEnterprise\grocerycrud\enterprise\src\GroceryCrud\Core\State\DependedRelationState.php
Line: 57
Function: getRelationalData
File: C:\xampp2\htdocs\grocery-crud-test\application\libraries\GroceryCrudEnterprise\grocerycrud\enterprise\src\GroceryCrud\Core\GroceryCrud.php
Line: 2433
Function: render
File: C:\xampp2\htdocs\grocery-crud-test\application\controllers\Examples.php
Line: 77
Function: render
File: C:\xampp2\htdocs\grocery-crud-test\index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Notice
Message: Undefined index:
Filename: Core/Model.php
Line Number: 271
Backtrace:
File: C:\xampp2\htdocs\grocery-crud-test\application\libraries\GroceryCrudEnterprise\grocerycrud\enterprise\src\GroceryCrud\Core\Model.php
Line: 271
Function: _error_handler
File: C:\xampp2\htdocs\grocery-crud-test\application\libraries\GroceryCrudEnterprise\grocerycrud\enterprise\src\GroceryCrud\Core\State\StateAbstract.php
Line: 1073
Function: getRelationData
File: C:\xampp2\htdocs\grocery-crud-test\application\libraries\GroceryCrudEnterprise\grocerycrud\enterprise\src\GroceryCrud\Core\State\DependedRelationState.php
Line: 57
Function: getRelationalData
File: C:\xampp2\htdocs\grocery-crud-test\application\libraries\GroceryCrudEnterprise\grocerycrud\enterprise\src\GroceryCrud\Core\GroceryCrud.php
Line: 2433
Function: render
File: C:\xampp2\htdocs\grocery-crud-test\application\controllers\Examples.php
Line: 77
Function: render
File: C:\xampp2\htdocs\grocery-crud-test\index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Notice
Message: Undefined index:
Filename: Core/Model.php
Line Number: 271
Backtrace:
File: C:\xampp2\htdocs\grocery-crud-test\application\libraries\GroceryCrudEnterprise\grocerycrud\enterprise\src\GroceryCrud\Core\Model.php
Line: 271
Function: _error_handler
File: C:\xampp2\htdocs\grocery-crud-test\application\libraries\GroceryCrudEnterprise\grocerycrud\enterprise\src\GroceryCrud\Core\State\StateAbstract.php
Line: 1073
Function: getRelationData
File: C:\xampp2\htdocs\grocery-crud-test\application\libraries\GroceryCrudEnterprise\grocerycrud\enterprise\src\GroceryCrud\Core\State\DependedRelationState.php
Line: 57
Function: getRelationalData
File: C:\xampp2\htdocs\grocery-crud-test\application\libraries\GroceryCrudEnterprise\grocerycrud\enterprise\src\GroceryCrud\Core\GroceryCrud.php
Line: 2433
Function: render
File: C:\xampp2\htdocs\grocery-crud-test\application\controllers\Examples.php
Line: 77
Function: render
File: C:\xampp2\htdocs\grocery-crud-test\index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Notice
Message: Undefined index:
Filename: Core/Model.php
Line Number: 271
Backtrace:
File: C:\xampp2\htdocs\grocery-crud-test\application\libraries\GroceryCrudEnterprise\grocerycrud\enterprise\src\GroceryCrud\Core\Model.php
Line: 271
Function: _error_handler
File: C:\xampp2\htdocs\grocery-crud-test\application\libraries\GroceryCrudEnterprise\grocerycrud\enterprise\src\GroceryCrud\Core\State\StateAbstract.php
Line: 1073
Function: getRelationData
File: C:\xampp2\htdocs\grocery-crud-test\application\libraries\GroceryCrudEnterprise\grocerycrud\enterprise\src\GroceryCrud\Core\State\DependedRelationState.php
Line: 57
Function: getRelationalData
File: C:\xampp2\htdocs\grocery-crud-test\application\libraries\GroceryCrudEnterprise\grocerycrud\enterprise\src\GroceryCrud\Core\GroceryCrud.php
Line: 2433
Function: render
File: C:\xampp2\htdocs\grocery-crud-test\application\controllers\Examples.php
Line: 77
Function: render
File: C:\xampp2\htdocs\grocery-crud-test\index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at C:\xampp2\htdocs\grocery-crud-test\system\core\Exceptions.php:271)
Filename: controllers/Examples.php
Line Number: 26
Backtrace:
File: C:\xampp2\htdocs\grocery-crud-test\application\controllers\Examples.php
Line: 26
Function: header
File: C:\xampp2\htdocs\grocery-crud-test\application\controllers\Examples.php
Line: 78
Function: _example_output
File: C:\xampp2\htdocs\grocery-crud-test\index.php
Line: 315
Function: require_once
{"total_count":4,"items":[{"id":null,"title":"Lyon"},{"id":null,"title":"Marseille"},{"id":null,"title":"Paris"},{"id":null,"title":"Toulouse"}]}