devidw/acf-helper

There is no license information available for the latest version (1.0.1) of this package.

Fund package maintenance!
devidw

1.0.1 2022-04-11 13:56 UTC

This package is auto-updated.

Last update: 2024-11-11 19:16:59 UTC


README

A set of PHP classes and methods to assist with ACF. Enables a straight forward way of working with ACF fields by providing a simple, clean and self describing intererface.

All methods are static and can be called directly from the class name from anywhere in the code.

The libary adds functionality to get the visibility state of a field and also provides a way to get the completeness amount of all fields in a field group based on the visibility state and the amount of filled fields by the user.

Installation

Install the libary using Composer:

composer require devidw/acf-helper

Comparison

Usage Examples

Get full field name

Gets the full field name of a field. Fields nested in fields like repeater, group or flexible content fields will also be returned as full field names.

With ACF you can only get the direct name of a field. This method allows you to get the full field name.

Let’s say you have a group of test_group_field and a sub field of test_sub_field in the group. Using the getName() method you can get the full field name of the sub field: test_group_field_test_sub_field.

<?php

require_once __DIR__ . '/vendor/autoload.php';

use Devidw\ACF\Field\Field;

$fieldName = Field::setKey('field_xxxxx')::getName();

dump($fieldName);

Credits to Adam for the StackOverflow answer.

Documentation

Documentation is available at https://devidw.github.io/acf-helper/api/