Manage forms

How to manage forms

Enabling the form builder

First, you need to enable the form builder to use it.

Go to the Settings page and find the "Content settings" section, enable the form builder and you are good to go.

Create the first form

To create a new template, navigate to the form list.

Click on the Create form button.

A modal appears, showing three fields:

  • Name - The form name

  • Label - The form label

  • Action - Choose the action between Ajax, Custom, Post Management or PHP

The form action determines its behavior.

Depending on the action, a few different fields will appear.

Ajax action

This action allows running a custom AJAX script to handle submitted form data.

The path of invoked AJAX action is required.

Your custom code is directly executed in the response of the AJAX call.

The data variable contains the Promise response value:

// data contains the Promise response

and can be directly used in your JS code.

Custom action

This action allows setting a custom form action.

You must also choose the form method (POST or GET).

Post Management action

This action allows saving ACPT meta fields.

There is no need for further configurations.

PHP action

This action allows running a custom PHP script to handle submitted form data.

ACPT rewrites $_POST and $_FILES global super variables, to be used in your script:

// $_POST and $_FILES store form data already sanitized
// by HandleFormSubmissionCommand class
$data = $_POST;
$files = $_FILES;

In the example code,$data now contains an array of form fields' sanitized values.

Meta fields mapping

Whatever action you choose, you need to specify the list of meta fields (coming from a group already saved) to populate the form builder.

You can choose between:

  • a Custom Post Type

  • a Taxonomy

  • an Option page

  • all users

The list of associated meta fields will appear immediately after.

You can select what fields you want to use in your form.

Optionally, you can specify the form target: a specific post, taxonomy, page, or user.

Once you are done, click on Save.

Now locate the Manage link on the forms table list to open the form builder.

Use the form on your website

After a form is created, a shortcode is automatically generated.

For example:

[acpt_form id="2db51086"]

Use this shortcode to use the form where you need it.

Last updated