Hi all,
I've got an N2N relationship and would like to hide the relation field and automatically (via code) set its value. I tried the following, but I get this error:
Unknown column 'Game' in 'field list'
Code:
//Main table $crud->setTable('item'); $crud->setSubject('Item', 'Items'); //Build relationship between games and items (make sure to hide reference fieldname, will add automatically before add & update) $crud->setRelationNtoN('Game', 'game_uses_item', 'game', 'ItemID', 'GameID', 'game_shortcode', null); $crud->unsetFields(['Game']); //On add and update, default to current game and move files from import folder to common_items function doAddOrUpdate($stateParameters, $inputFilePath, $gameID) { //Default to current game $stateParameters->data['Game'] = $gameID; //Move files to common_items return doImportMove($stateParameters, $inputFilePath); } //Once data saved to db, need to move files to correct location $crud->callbackBeforeInsert(function ($stateParameters) use ($inputFilePath, $gameID) { return doAddOrUpdate($stateParameters, $inputFilePath, $gameID); }); //Once data saved to db, need to move files to correct location $crud->callbackBeforeUpdate(function ($stateParameters) use ($inputFilePath, $gameID) { return doAddOrUpdate($stateParameters, $inputFilePath, $gameID); });
It looks like "Game" field is being removed from the entire dataset. Is there any way to do this?
Cheers,
Dave