The Error: 0 - Invalid controller: name='visforms', format=''
In 2016, we started to receive some notifications on our forum, that some users experienced this error while using Visforms in a module or inside an article. Sadly for a long time it was not possible to reproduce the problem in a way, that I could debug it, even with the support of the users who experienced the problem, until I finally got my hands on a Joomla! installation, where I could reproduce and debug this problem.
This is quite a delicate problem and it has, as I suspected, everything to do with side effects between different third party extensions for Joomla!. If this error occurs it is the result of a bad configuration of your website and it is very difficult to debug (and what causes the problem in the first place is probably different in every case). Nevertheless there are some common points of leverage, that might help you, fix the problem on your website.
I will explain the process, that causes the problem and where you might start looking on your webseite for solutions in as much detail as possible.
There are a lot of conditions, which have to be met, in order for this problem to occure, but basically it is caused, because the Joomla! default router cannot detect, that it has to use the Visforms router for parsing an incoming url. As a result Joomla! does not notice, that the component which is actually called and where the controllers can be found is Visforms. Joomla! starts searching in the wrong place and therefore does not find the controller.
The Joomla! default router uses the url and tries to extract which component router has to be used. This is a step by step approach. During this process, the url is converted to a JUri object, that can be used to extraxt specfic information about the url, for example like the basepath, the path, url parameters and so on, easily. As Joomla! supports the use of plugins and such plugins can hook into the Joomla! code before the Joomla! router kicks in (using the onAfterInitialise event), it is possible to provide the Joomla! router with an JUri object with invalid detail information. It is mostly system plugins that use the onAfterInitialise event but it might be used by other plugin types as well.
If you have for example a multi language website and use Visforms in a module or with the content plugin form view, then the SEF-Url which is used, if the a user submits the form would be
http(s)://yourDomain/languageCode/component/visforms/?view=visforms&task=visforms.send&id=yourFormId
In this case the path variable in the JUri object would be yourDomain/languageCode/component/visforms
. Before this path is delivered to the Joomla! router, the yourDomain is removed and the system plugin languagefilter preprocesses the JUri using the onAfterInitialise event to removes the language code, so that the Joomla! router actually receives a path variable which is component/visforms
.
The Joomla! router is only able to figure from such an url, which component is to use, if the first segment of the path is exactly the string "component". It then uses the second segement in order to figure, which component router to use and through that information, which component to use.
There might be many plugins, that use the onAfterInitialise event on your website. Which plugin comes first is determined by the plugin order (which is determined in the plugin manager in the administration of your website).
If now, there is a plugin that uses the onAfterInitialise event and triggers routing of the url and is called before the system plugin languagefilter and does not look itself if there is a languageCode as first segment in the path variable of the JUri object, then the path variable would bei languageCode/component/visforms
instead of component/visforms
and the Joomla! cannot resolve the component and its router properly.
Therfore the Joomla! router starts with an alternative way to figure, what component to use with the url. It looks, if there is an url parameter Itemid (which always is the id of a menu item) and if so, it uses the information from the menu item for routing. As our example url obviously has no Itemid and cannot have one, because the form is not displayed by a menu item of type Visforms, the Joomla! router cannot resolve the url properly by this approach either. Therefore it falls back on the default, which is using the "home" menu item (default menu item) in order to detect which component router and which component is to use. As the home menu item usually is not a menu item of type Visforms, Joomla! does not look in the Visforms component folder for the proper controller and therefore just does not find the necessary files. As a result the error message "Invalid controller: name='visforms', format=''" is thrown.
How to fix it?
In Visforms 3.10.0 we have added an new option to the module configuration which can help you solve such a problem. Create a menu item of type Visforms >> form for the form which you publish with the module of type Visforms. The menu item must be published but it can be part of a so called hidden menu, that is a menu, which is not linked to menu module and therefore not published on your website. Then go back to the module configuration of the module of type Visforms. Select the menu item of this menu in the select "Corrresponding Menu Item".
If that does not solve the problem you have to find out, which plugin is causing the problem. Mostly probably it is a system plugin. So a good point to start is, to disable all non Joomla! core system plugins. After that, sending a form that is displayed in a module or an article should work again. (But of course there may be other reasons that break the Joomla! router, for example, if multiple languages are not set up proberly on a multi language page. In this case you have to find out first, what breaks the Joomla! router). Then start enabeling the disabled system plugins one by one, each time testing, if sending the forms still works. If you have found the plugin (or maybe it is more than one as in our case), you have to decide what to do with them. Is there a way, to make them work properly with the Joomla! router? In our case, moving the plugins below the system plugin languagefilter was enough to solve the problem. But there may certainly be plugins, where this is not working. Sadly, there is no "global" solution then and this article is more about helping you to understand the problem, then, so that you might be able to figure the proper solution for your website yourself.