Adding Metaboxes

NOTE: This document pertains to adding metaboxes in NF Core >=v3.6.1.

As part of our Submissions page migration, we changed how metaboxes are displayed on the page. Note that no data is affected by this change, only how it is output on the page when viewing an individual submission.

Metabox data is primarily stored as $extra data during the form processing, and thus is triggered by data stored under a key in that $extra data.  To trigger output, you will add your own handler class to our array of handlers using a filter.

In the above snippet, we hook a function to the nf_react_table_extra_value_keys filter and in this function, we add to an incoming array the name of a handler class and we key this class name on the $extra data key we want to output. Note that in the filter, you provide a fully namespaced class name.

The next step is to then create our handler class. This handler class requires one public function – to generate the structure for output. When a submission is output, if it includes $extra data stored under your registered key, NF core will call your handler class and provide two parameters – the $extra data stored and the full NF submission object. By providing both, you can output more than just the $extra data – you have access to the entire submission for constructing whatever you wish with the submission data.

The output you provide will be structured as an indexed array of keyed arrays – each indexed array corresponds to a line of output in your metabox. Within your class you have the freedom to construct as many lines of metabox output as needed.

If, based on the data, you decide you do not need to output anything, your handler class can return null to cancel the output.

When on an individual submission page, the above output is a simplified version of Authorize.net’s output as shown in this screen shot:

authorize.net metabox sample

This metabox appears as shown in this screen shot:

single submission with metabox

author’s note: please don’t hesitate to reach out to us if you have any questions on this documentation.  We’d be happy to answer your questions and update the documentation for better clarity.