Home Forums General Issues New ACF type to store multiple fields or arbitrary data


New ACF type to store multiple fields or arbitrary data

  • Hello! I am trying to create a new field type for ACF that contains multiple inputs or stores an array of values. The reason is that I would like to have some interactivity and a custom layout for a group of input fields.

    I followed your tutorial and used the provided template: which is really nice and well documented. Storing one value is pretty simple but how can I use multiple inputs?

    I would also like to know if it is possible to store arbitrary data (for example an array) without having to use an html input field. Let’s say my custom field is an html5 canvas element where the editor can draw a path and I want to store the anchor points from that path in a custom field.


  • Hi, I am trying to do something like that as well, here is what i got so far:

    lets say you have a custom field with the name “field_1” and one with the name “field_2” and you want the field to return the $value as an array:

    make sure that you custom field html got some input with name="field_1" and name="field_2" in the function update_value(); of your custom field put something like:

     if( $value ) {
         //an array to hold your values
         $all_values = array();
         $all_values['field_1'] = $value['field_1'];
         $all_values['field_2'] = $value['field_2'];
         return $all_values;

    the value of your field is now an array like:

    array(2) {
    string(4) “one ”
    string(3) “two”

  • It’s not necessary to write a custom update_value function, saving multiple values in one field can be done simply by choosing the right input field names.

    Have a look at this thread, where it is explained in detail:

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘New ACF type to store multiple fields or arbitrary data’ is closed to new replies.