Creating a form
Forms can be created either using the UI provided or programmatically.
Using the admin interface
To create a form using the UI navigate to the “Forms” admin page and create a new form. Use the form settings to set up entries, emails and display options. At the bottom you will find a list of all fields which are connected to your form.
The fields connected to a form are fully defined by Advanced Custom Fields allowing you to use the full range of field types offered by ACF. To connect a field group to your form set its location rule to match. This can be done in the ACF field group UI by adding a location rule and setting it to “Form” -> “is equal to” -> your form title.
Registering your forms programmatically is great if you want to integrate Advanced Forms with your theme or plugin. In the future the plugin will include an export feature to generate form code from a form created using the admin interface.
To create a form programmatically the function
af_register_form( $form ) is provided. The $form parameter should be an array matching the structure in the following example.
Note that the only required attribute is key which should be a unique identifier for your form starting with
"form_". Setting the title attribute is recommended.
It’s recommended to register your forms on the
af/register_forms hook to ensure that both Advanced Forms and ACF are installed and ready.
If you are adding ACF field groups programmatically using the function
acf_add_local_field_group then you need to set your ACF location rule to match your registered form. Adding your form as a location rule is simple and can be done like this: