Home › Forums › ACF PRO › Creating Repeater field with Post Object in PHP › Reply To: Creating Repeater field with Post Object in PHP
Thanks for looking into this,
I did as you suggested and renamed these as detailed below.
$session_client = array(
"key" => "field_session_clients_client",
"label" => "Client",
"name" => "client",
"type" => "post_object",
"post_type" => array(
"cp-client"
),
"return_format" => "object",
'instructions' => "",
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'taxonomy' => array(),
'allow_null' => 0,
'multiple' => 0,
'ui' => 1
);
acf_add_local_field(array(
"key" => "field_session_clients",
"label" => "Clients",
"name" => "session_client",
"type" => "repeater",
"sub_fields" => array(
$session_client
),
"parent" => "group_session",
'instructions' => "",
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'collapsed' => '',
'min' => 0,
'max' => 0,
'layout' => 'table',
'button_label' => ''
));
Just a note though, I had created 3 other field groups and related fields in the same format as above and none of these posed any problems. I assumed that the “field_” and “group_” keys were just conventions rather than required.
I did a bit of digging and placed the following code at line 201 of /includes/api/api-field.php to see what was happening as this was where the first notice was occurring:
if(!$field['_name']) print_r($field);
The array is printed out if “_name” is not set. I checked the other repeaters I had used in other areas and this is triggered in those places also. These repeaters store and retrieve data just fine despite “_name” not being set but these only have text fields as children rather than post_object.
I even flushed the database just in case there was soemthign lurking in there somewhere using WordPress Database Reset but the issue still persists.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.