Support

Account

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

  • 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:

    `[“value”]=>
    array(2) {
    [“field_1”]=>
    string(4) “one ”
    [“field_2”]=>
    string(3) “two”
    }