Porting custom module from 1.8.13 to 2.3.5

In my module, I worked on editing the twig file (modulename-form-edit.twig) to make it so some form elements could be shown or hidden based on actions within the form. Previously this was done via ‘{% block formFieldActions %}’ in the twig file but I cannot determine how that is done in 2.x. Can you point me in the correct direction?

OK, so after a lot of searching, I figured out that this has been moved to javascript contained within the modulename-designer-javascript.twig file. Now that I figured this out, I have created that file in the /custom/Modulename/ folder but it does not appear to be loading. I went ahead and added a comment contained with the function to search for in DevTools and could not find it. I modified another module’s code and was able to find the comment for that module. As such, I am stuck. Thoughts? I am testing my code on 2.3.5.

I was able to find what was missing to load the JavaScript code. In the main module code file, the following needs to be added to load the file:

/**
 * Javascript functions for the layout designer
 */
public function layoutDesignerJavaScript()
{
    return 'modulename-designer-javascript';
}

Adding the above code and creating the modulename-design-javascript.twig file with the necessary JavaScript within it will allow you to show/hide elements within the Edit form.

Sorry I did not get to this before you solved it.

For anyone running into this problem again, we have a guide for it here: https://xibo.org.uk/docs/developer/upgrading-your-custom-module-to-cms-version-2

The Xibo Community site uses cookies. What are cookies?