The gform_pre_render filter is executed before the form is displayed and can be used to manipulate the Form Object prior to rendering the form. It is generally used to dynamically populate form controls before the form is rendered.
Checkbox controls are special, in that they are treated as multi-input fields (similar to “Name” and “Address” fields). Besides the “
choices” property which they share with “select”, “multi-select” and “radio” controls, they also have an “
inputs” property. Please check the Field Object documentation page for more details.
Because of this, dynamic population for checkbox controls is somewhat different compared to the other multi-choice field controls.
The following approach can be used for checkboxes: on “gform_pre_render” use
RGFormsModel::get_form_meta() method to fetch the form from database, then populate the form controls as required, and then the form is saved back to the database using
RGFormsModel::update_form_meta(). This behaviour can be controlled using a boolean constant, as shown below:
Using this approach you can view the checkbox values in the entry list as well as change the entry, by updating the submitted checkbox values.