Interfacing further forms packages

The following information is aimed at developers. Either the developers of forms packages or experienced developers who can find their way through the code of forms packages.

Knowing your way round the interfacing forms package is the hard part. The easy part is interfacing that to Magic Data Forms. You only need to create a single model class and place it in the appropriate directory and file, either in a package or as a root level model.

/models/magic_data_forms/form_interfaces/your_interface_name.php

or

/packages/your_package_name/models/magic_data_forms/form_interfaces/your_interface_name.php

Your interface model should begin with the class definition

Loader::library('magic_data_forms_form_interface_plugin_base', 'jl_magic_data_forms');
class MagicDataFormsFormInterfacesYourInterfaceName extends MagicDataFormsFormInterfacePluginBase {
    // interface code
}

The convention for the file name, class name and location are all Magic Data Forms needs to locate a new form interface plugin. It will scan for new form interfaces whenever the Magic Data Forms dashboard page is visited. If the new form plugin is being added as part of a package, the package controller can also automatically re-scan plugins on install and upgrade. There is example re-scan code in the package controller for Magic Data Forms that developers are welcome to use.

The place to start designing a new form interface plugin is by looking at the source of the abstract class MagicDataFormsFormInterfacePluginBase, in the file:

/packages/jl_magic_data_forms/libraries/magic_data_forms_form_interface_plugin_base.php.

Developers should also look at the code for the core form interface that inherits from this base, MagicDataFormsFormInterfacesCoreForm. Each form interface will necessarily be different, but this will explain how the inheritance from the abstract class was implemented in one particular instance.

/packages/jl_magic_data_forms/models/form_interfaces/core_form.php

The only methods an interface must provide are the abstract methods. The other methods in this class can happily be inherited and will then work things out for themselves, though may not be particularly efficient, especially when a form has lots of results.

When developing a new form interface plugin you can begin by implementing just the abstract methods, test the code with some examples, then add further overrides where they improve efficiency.

40 forms page.png

Developers are welcome to use code from Magic Data Forms CSV Interface when developing further form interfaces for Magic Data Forms. Please contact me to discuss implementation details.

Last updated: over a year ago