Download the PHP package flyntwp/acf-field-group-composer without Composer

On this page you can find all versions of the php package flyntwp/acf-field-group-composer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package acf-field-group-composer

acf-field-group-composer

standard-readme compliant Build Status Code Quality Code Coverage

Configuration builder for advanced custom fields field groups

This plugin helps you create reusable ACF fields and field groups with code.

Table of Contents

Background

ACF provides a great interface to create custom meta boxes in WordPress. However, there are to major downsides using it out of the box:

  1. Configuring ACF via its GUI can be cumbersome if you have a lot of custom fields. Also fields created via the GUI are only stored in the database. This means that migrating fields between different stages of a development setup can only be done by migrating the database as well.
  2. The local JSON feature and add_local_field_group are handy for checking the config into SCM and deploying it to different environments, but it lacks some customizability, like reusing previously specified fields in different contexts.

The acf-field-group-composer helps circumventing these downsides. It let's you use the build-in add_local_field_group function, and automatically adds unique keys to all fields added. Plus, if a field is not an array but a string, it will apply a filter with that name and use the return value as a new field in the config.

Install

TODO: install via WordPress instructions

To install via composer, run:

Usage

To register a field group run:

The $config variable should be of the same format as the one you would pass to acf_add_local_field_group. There are only two things that are different:

  1. You do not have to specify a key in any field or group.
  2. A field group requires a unique name property.

Following the minimal example from ACF:

In order to make use of the additional functionality of acf-field-group-composer you can extract the specified field and return it in a filter. The name of the filter can be anything, but we recommend a meaningful naming scheme. For example:

The same can be done for the location:

Combining the previous steps will yield the following result:

Executing this code will add a field with the name subtitle to all posts. The key will be a combination of the field group name, all parent field names (if the field has parent fields), and the field's name itself. In this case, this is field_group1_subtitle.

Filter arguments

There is another caveat when working with reusable components in ACF. While the flexible content field from ACF Pro gives you everything you need for adding multiple components of the same type to one field group, this is not possible for regular field groups.

For example, if you define a set of fields for a simple WYSIWYG component and then want to add it to a field group multiple times, the result will be two Wysiwyg components being displayed, but each one would have the same name, and thus overwrite each other's data.

This can be fixed by adding a filter argument. All filter arguments must be appended with #. Once this is done, the respective filter will be called with the suffix as a second argument, and the field names will be prefixed with that string.

For example, taking the previous broken code an adding two unique filter names will resolve the problem:

As a result, the following two fields are added to all posts:

name key
firstWysiwyg_content field_group1_firstWysiwyg_content
secondWysiwyg_content field_group1_secondWysiwyg_content

These field can be accessed as usual through the ACF functions get_field() and get_fields().

Conditional logic

Conditional logic can be added to a field in the same way as in ACF. The exception is that we can pass fieldPath instead of field. The fieldPath must reference the name of a field defined in the same config:

To reference a field in conditional logic when inside a nested sub field (for example, in a repeater), the fieldPath must be passed relative to the current level. For example:

API

ACFComposer\ACFComposer (class)

registerFieldGroup (static)

The main function of this package. Resolves a given field group config and registers an acf field group via acf_add_local_field_group.

ACFComposer\ResolveConfig (class)

forFieldGroup (static)

Validate and generate a field group config from a given config array by adding keys and replacing filter strings with actual content.

forField (static)

Validate and generate a field config from a given config array by adding keys and replacing filter strings with actual content.

forLayout (static)

Validate and generate a layout config from a given config array by adding keys and replacing filter strings with actual content.

forLocation (static)

Validate a location config from a given config array.

Maintainers

This project is maintained by bleech.

The main people in charge of this repo are:

Contribute

To contribute, please use GitHub issues. Pull requests are accepted. Please also take a moment to read the Contributing Guidelines and Code of Conduct.

If editing the README, please conform to the standard-readme specification.

License

MIT © bleech


All versions of acf-field-group-composer with dependencies

PHP Build Version
Package Version
Requires composer/installers Version ~1.0 || ~2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package flyntwp/acf-field-group-composer contains the following files

Loading the files please wait ....