Title: Repeating fields
Last modified: August 31, 2016

---

# Repeating fields

 *  [friendofdog](https://wordpress.org/support/users/friendofdog/)
 * (@friendofdog)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/repeating-fields-4/)
 * Can Form to Post handle repeating fields?
 * I have a form which takes multiple values in a single field. For example, if 
   a user checks off the following…
    [ ] class 1 [x] class 2 [ ] class 3 [x] class
   4 [x] class 5 … it would return the value “array(‘class 2′,’class 4′,’class 5’)”
   to a hidden CF7 text field. I’m trying to get this into a repeating field when
   FtP creates the post.
 * If it matters at all, I’m using the plugin ACF Repeater Fields.
 * [https://wordpress.org/plugins/form-to-post/](https://wordpress.org/plugins/form-to-post/)

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

 *  Plugin Author [Michael Simpson](https://wordpress.org/support/users/msimpson/)
 * (@msimpson)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/repeating-fields-4/#post-7057585)
 * I’m not familiar with that plugin. Is this something you are using to set custom
   fields in the post? In which case the hidden field’s name should start with “
   meta_”. I think it should handle setting multiple values in the same field.
 * If I’m not understanding, please provide more context about ACF Repeater Fields.
 *  Thread Starter [friendofdog](https://wordpress.org/support/users/friendofdog/)
 * (@friendofdog)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/repeating-fields-4/#post-7057667)
 * I looked into this a bit further and it’s a bit more complicated than I originally
   thought. ACF has its own method of creating posts, and with [Repeater Fields](http://www.advancedcustomfields.com/resources/repeater/)
   I found no other solution than to use ACF’s method.
 *     ```
       $field_key = 'field_123123123123'; // corresponds with a meta_ field
       $subfield_key = 'field_456456456456'; // repeating sub-field of $field_key
       $post_id = $the_post_id; // gets the current post ID
       $items = array('foo','bar','meh','cat','dog');
       foreach ($items as $items_value) {
       	$value[] = array($subfield_key => $items_value);
       	update_field( $field_key, $value, $post_id );
       }
       ```
   
 * The issue is that you when you use Repeater Fields, you can’t get a meta_ field
   by its name. You have to get it by its field key, which is generated by ACF when
   you create a custom field. Repeater sub-fields also have their own field keys.
 * Also, I couldn’t get this to work with update_post_meta, which FtP uses. I had
   to use update_field (which is native to ACF).
 * Sorry, I thought this would be an open-and-shut issue. I’ve posted a similar 
   question on ACF’s forums – if they indicate a solution that allows FtP integration,
   I’ll share it here.
 *  Plugin Author [Michael Simpson](https://wordpress.org/support/users/msimpson/)
 * (@msimpson)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/repeating-fields-4/#post-7057675)
 * Thanks for writing back. Note that there are a couple of hook in F2P, form_to_post_before_create_post
   and form_to_post_set_values. Perhaps you can add code to those and call ACF functions
   to do what you want.

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

The topic ‘Repeating fields’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/form-to-post.svg)
 * [Form to Post](https://wordpress.org/plugins/form-to-post/)
 * [Support Threads](https://wordpress.org/support/plugin/form-to-post/)
 * [Active Topics](https://wordpress.org/support/plugin/form-to-post/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/form-to-post/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/form-to-post/reviews/)

## Tags

 * [custom field](https://wordpress.org/support/topic-tag/custom-field/)

 * 3 replies
 * 2 participants
 * Last reply from: [Michael Simpson](https://wordpress.org/support/users/msimpson/)
 * Last activity: [10 years, 3 months ago](https://wordpress.org/support/topic/repeating-fields-4/#post-7057675)
 * Status: not resolved