Support

Account

Home Forums Front-end Issues Allow specific fields from repeater field on frontend form

Solved

Allow specific fields from repeater field on frontend form

  • Is it possible to have some specific repeater fields to display on frontend form. for example look at the “fields” parameter in below example.

    $options = array(
    	'field_groups' => ['group_602a592cf1805'],
    	'fields' => [
    			'my_name', //normal ACF field, (this works!)
    			'test_repeater_field' => ['hello'], //allowing only specific field with in a repeater field, (Not working)
    		],
    	'form_attributes' => array(
    		'method' => 'POST',
    		'action' => admin_url("admin-post.php"),
    	),
    	'html_before_fields' => sprintf(
    		'<input type="hidden" name="action" value="save_user_fields_form">
        <input type="hidden" name="user_id" value="user_%s">',
    		$user->ID
    	),
    	'post_id' => "user_{$user->ID}",
    	'form' => true,
    	'html_submit_button' => '<button type="submit" class="button margin-top-20 margin-bottom-20" value="Update Profile">' . __('Submit', 'text-domain') . '</button>',
    );
    
    acf_form($options);
  • You can do this using field keys, however, it still will not work the way you expect it to work without including the entire repeater. The reason is that ACF will not know when this field is submitted that you want to add a row to a repeater.

    To accomplish what you intend you will need to create a new field group that has the fields you want on the front end form. Then you will need to create an acf/save_post action that gets the values of these fields and adds a row to the repeater field.

  • Can you share more instruction please? I have a group inside of a repeater. Trying only display one field in the frontend form for each of the rows in the repeater. I’m able to see the field, but it doesn’t update the row.

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

You must be logged in to reply to this topic.