User tests: Successful: Unsuccessful:
Pull Request for Issue #17708
as title says
Create a new menu item of type "Create Article"
In the Options tab, set Default Category to Yes
Do NOT select a category in the field below which only displays by a showon.
Save menu item.
The menu item is saved. No error is set.
Category id was wrongly set to 1, which wrong behaviour is now corrected in frontend, among other issues with permissions, with #17674
Preventing saving and displaying an error message
Status | New | ⇒ | Pending |
Category | ⇒ | Administration com_menus Language & Strings |
Labels |
Added:
?
?
|
I'm assuming that the obvious option of making the field required is not used for a valid reason
It's impossible as the field should be ignored when Default category is set to no and we do not have a specific "requiredon" (on the model of "showon" code).
COM_CONTENT_CREATE_ARTICLE_ERROR="When default category is enabled, a category should be selected."
As its an error message not a help doc this can be rewritten to something like
COM_CONTENT_CREATE_ARTICLE_ERROR="A default category is required."
Why not give this detail? It does not cost much and help user solve the issue. grrr
I have tested this item
I have tested this item
I have tested this item
@franz-wohlkoenig Last change after your test was just a language change, so you can just set your test result again without retest, just review last change, and then RTC
Don't worry about appveyor btw.
I know.
Status | Pending | ⇒ | Ready to Commit |
Status "Ready To Commit".
Labels |
Added:
?
|
Sorry to say but this solution is really hacky in my opinion that should be done in a plugin for example content->joomla in the on_before_save event.
@HLeithner
I would not know how to do what you suggest.
@HLeithner I would also not know. I have an idea what you mean but I'm not good enough in event based stff to do it either. And it has 2 good tests, one from me. And I would not call it "hacky", only maybe "old style but working". So for me it's pretty fine.
P.S.: And it fixes an issue.
@richard67 writing a hardcoded string into com_menu because a specific other component needs it is wrong. It's possible that we don't have another way but if we have the choice we should use it.
Please but this in to plg_content_joomla + the language string.
/**
* The save event.
*
* @param string $context The context
* @param object $table The item
* @param boolean $isNew Is new item
* @param array $data The validated data
*
* @return void
*
* @since __DEPLOY_VERSION__
*/
public function onContentBeforeSave($context, $table, $isNew, $data)
{
// Check we are handling the frontend edit form.
if ($context !== 'com_menus.item')
{
return true;
}
// Special case for Create article menu item
if ($table->link !== 'index.php?option=com_content&view=form&layout=edit')
{
return true;
}
// Display error if catid is not set when enable_category is enabled
$params = json_decode($table->params, true);
if ($params['enable_category'] == 1 && empty($params['catid']))
{
$table->setError(JText::_('PLG_CONTENT_JOOMLA_CREATE_ARTICLE_WITH_EMPTY_CATEGORY_ERROR'));
return false;
}
}
@HLeithner Is not my PR, is @infograf768
will test. No idea what happens btw in general when that plugin is disabled.
Category | Administration com_menus Language & Strings | ⇒ | Administration Language & Strings Front End Plugins |
@richard67 @HLeithner
used plugin instead. Please test.
(The lang string has to remain in com_content.ini as that plugin is not loading its lang files in the page concerned.)
I have tested this item
@franz-wohlkoenig Could you test again?
I have tested this item
I have tested this item
Thanks for catching this error.
Status | Ready to Commit | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2019-08-27 11:24:13 |
Closed_By | ⇒ | HLeithner |
I'm assuming that the obvious option of making the field required is not used for a valid reason
COM_CONTENT_CREATE_ARTICLE_ERROR="When default category is enabled, a category should be selected."
As its an error message not a help doc this can be rewritten to something like
COM_CONTENT_CREATE_ARTICLE_ERROR="A default category is required."