We discovered a problem today with a common workflow that our team uses. We have many categories on our magazine sites so if someone is entering a number of articles in the same category it saves time to filter the Articles listing by that category. This way when hitting the New button to create a new article the category is already set. The problem is that when filtering or when an article has multiple categories the category is an array of integers instead of an integer which causes a 500 error of Unknown column 'Array' in where clause.
Poking around in the content plugin onContentPrepareForm() function I was able to write a fix that is more general than the assumption of a single category for determining if the Image field tab loads. I made the assumption that if ANY category in the list enables the field then the field is enabled and only loaded once. I also generalized by converting the category ID to a single element array if it is not an array already. Hopefully you can fold this fix into your next release so we don't have to maintain a patch here.
Thanks,
Oliver
code snippet from plugins/content/econa/econa.php - onContentPrepareForm()
Poking around in the content plugin onContentPrepareForm() function I was able to write a fix that is more general than the assumption of a single category for determining if the Image field tab loads. I made the assumption that if ANY category in the list enables the field then the field is enabled and only loaded once. I also generalized by converting the category ID to a single element array if it is not an array already. Hopefully you can fold this fix into your next release so we don't have to maintain a patch here.
Thanks,
Oliver
code snippet from plugins/content/econa/econa.php - onContentPrepareForm()
// Article form elseif ($name == 'com_content.article') { $categoryIds = is_object($data) ? $data->catid : $data['catid']; if ($categoryIds) { // force array if (!is_array($categoryIds)) { $categoryIds = [ $categoryIds ]; } foreach ($categoryIds as $categoryId) { $category = JTable::getInstance('Category'); $category->load($categoryId); $categoryParams = new Registry(); $categoryParams->loadString($category->params); if ($categoryParams->get('enable_image_tab', 1)) { JForm::addFormPath(__DIR__ . '/forms'); $form->loadFile('econa', false); // only load field once break; } } } else { JForm::addFormPath(__DIR__ . '/forms'); $form->loadFile('econa', false); } }