Home › Forums › Feature Requests › Repeater: default fields/data › Reply To: Repeater: default fields/data
A clean approach here tested in version 5.5.7, you can just set a default value in the repeater field like this (note: you need to do these edits in the PHP export code. Note 2: Check the ‘default_value’ key passed to the array):
array (
'key' => 'key_58c7ee3a37aee',
'label' => 'Table',
'name' => 'table',
'type' => 'repeater',
'instructions' => '',
'required' => 1,
'conditional_logic' => 0,
'wrapper' => array (
'width' => '',
'class' => '',
'id' => '',
),
'collapsed' => '',
'min' => 0,
'max' => 0,
'default_value' => array(
array(
'field_58984ddb5b8cc' => 'My title',
'field_58985045abac0' => 'My content',
),
array(
'field_58984ddb5b8cc' => 'Another title for a content-less row',
),
),
'layout' => 'table',
'button_label' => 'Add Row',
'sub_fields' => array (
array (
'key' => 'field_58984ddb5b8cc',
'label' => 'Title',
'name' => 'title',
'type' => 'text',
'instructions' => '',
'required' => 1,
'conditional_logic' => 0,
'wrapper' => array (
'width' => '40%',
'class' => '',
'id' => '',
),
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'maxlength' => '',
'readonly' => 0,
'disabled' => 0,
),
array (
'key' => 'field_58985045abac0',
'label' => 'Content',
'name' => 'content',
'type' => 'text',
'instructions' => '',
'required' => 1,
'conditional_logic' => 0,
'wrapper' => array (
'width' => '60%',
'class' => '',
'id' => '',
),
'default_value' => '',
),
),
),
Hope this saves someone’s time,
Cheers !
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.