Download the PHP package trendwerk/acf-forms without Composer
On this page you can find all versions of the php package trendwerk/acf-forms. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download trendwerk/acf-forms
More information about trendwerk/acf-forms
Files in trendwerk/acf-forms
Package acf-forms
Short Description Helper to use ACF forms in the front-end.
License GPL-3.0+
Informations about the package acf-forms
ACF Forms
Active development for this package has been discontinued.
Helper package to use ACF forms in the front-end. What it does:
- Adds the ability to send notifications
- A default "Admin" notification
- Saves entries to the database
- Adds a wrapper around
acf_form
that does the repetitive work
This package requires Advanced Custom Fields Pro v5 to be installed.
Quick links: Example
Install
Usage
Creating and showing a form with this package consists of four parts:
- Initialize package
- Create field group
- Register form
- Render form
Initialize
This code should be run when bootstrapping your theme (traditionally done via functions.php
). Initialization creates the entries
post type and sets up defaults form handlers and notifications.
Create field group
Create a new field group in Advanced Custom Fields. When choosing a location where to show this field group, make sure you use Forms > Front-end
is equal to Yes
.
Register form
Parameter | Default | Required | Description |
---|---|---|---|
$name |
null |
Yes | (Unique) name / slug of the form |
$options |
null |
Yes | Array with options. See Options. field_groups is a required property. |
Render
Rendering a form consists of two parts:
- Displaying the form
- Handling form data and enqueue-ing scripts (
Form::head()
)
For example:
In reality, the render
method will be called somewhere inside your actual template.
Options
Parameter | Default | Required | Description |
---|---|---|---|
acfForm |
null |
Yes | Options passed to the acf_form function. field_groups is a required property. |
label |
null |
No | Label used in the e-mail subject and entry title. If left empty, the unique form name will be used |
notifications |
['Trendwerk\\AcfForms\\Notification\\Admin'] |
No | Notifications that are sent via e-mail after form submission. See Notifications |
Notifications
Notifications can be created by extending the Notification
abstract class or the default Admin
notification class.
Example
The example below walks through all three steps of creating and showing a form, based on a field group. This example uses Twig, Timber and Sphynx.
functions.php
Field group keys can be found when showing the slug
of the field group or in the corresponding JSON file.