Skip Navigation

[Resolved] Delete Repeatable Field Group in Front-end Form

This thread is resolved. Here is a description of the problem and solution.

Problem:
In a View listing repeatable field groups, how to show a delete button to delete a group.

Solution:
Repeatable field groups are implemented as posts, each post storing one group of custom fields.

A View displaying repeatable field groups is displaying these posts, and any one post can display a delete button if you have Toolset Forms active.

Use the Toolset Forms button to insert the Delete Post Link.

This support ticket is created 5 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

Author
Posts
#1257907
sc1.png

Hi!

I created a page for editing Repeatable Field Group according to your documentation:
https://toolset.com/documentation/getting-started-with-toolset/creating-and-displaying-repeatable-field-groups/front-end-forms-for-repeatable-field-groups/

It turned out great, but besides editing the Repeatable Field Group need to add a Delete button for each of the Repeatable Field Group next to the Save button (see screenshot),

I did not find in the documentation how to add such functionality to the editing form Repeatable Field Group,

Help me please!

#1258169

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Screenshot 2019-06-04 at 12.18.17.png

Hi there

Repeatable field groups are implemented using posts to act as containers for each group of fields, so the action you require when listing posts in a View that contain edit buttons to edit the posts is delete post.

In much the same way you would insert an edit link, use the Toolset Forms button to insert a delete post link (screenshot).

#1258245
sc2.png

Hi Nigel!

Thanks for the help!

I inserted a button to delete the post according to your instructions in View loop,

when pressing this button the Repeatable Field Group is removed from the database, but on the site after this operation a blank screen remains with a link in the URL:

/wp-admin/admin-ajax.php?action=cred-ajax-delete-post&cred_post_id=255&cred_action=delete&redirect=0&_wpnonce=93475c5643&_cred_link_id=_cred_cred_255_5&_cred_url

Choosing any action after deleting (see screenshot) does not solve the problem,

Looks like I need more help. )))

#1258309

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Alex

I just tested this on my local site to double-check whether it works, and it did, very much as expected/intended.

Let me just describe the set-up to make sure we are talking about the same thing.

I have a custom post type, and a custom field group assigned to that post type includes a repeatable field group.

I create a View where that repeatable field group is the content selection and which includes a Query Filter to connect the RFGs to the page where the View is displayed.

In the output section I'm just outputting the post title (i.e. the title of the RFG) and a delete post link inserted using the Toolset Forms button with the defaults.

I then insert this View into the Content Template to display my custom posts.

When I visit one of these custom posts on the front end I see the list of RFG titles together with the delete links.

In my case I tested with the option to reload the page, and that worked, so I stopped there.

If your set-up is essentially the same and it is not working then we should eliminate the possibility of conflicts, e.g. if you are using a page builder.

Could you please disable all non-Toolset plugins and switch theme to twentynineteen then try again. If the issue disappears then it should be possible to determine the source of any conflict by a process of elimination.

Let me know how that goes so I can see how to proceed.

#1258417
sc5.png
sc4.png
sc3.png

Yes,

Everything seems to be the same, but just in case I made screenshots of all the settings of View (sc3, sc4,sc5), see if everything is right there?

This View I insert into the content template associated with the post at which these RFG.

Once again I want to note that the groups are deleted from the database, i.e. the button works, only the transition does not work (page reload) after that.

I cannot change the theme and turn off related plugins, because this is an Intranet theme (not a public site), and when it is turned off, I can no longer check anything.

This theme:
hidden link

I admit that this may be a conflict with the theme, but it is probably possible to get around this bug with a suitable filter (add_filter) or action (add_action)??

Thanks!

#1258477

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Everything in the screenshots looks correct.

I can't propose a solution without knowing the cause of the problem.

Is it possible to install a site duplicate to install on another server, or provide a copy of the site where I can do the same.

If not, can you create a test site with sample data and install the theme and check if it is the source of any conflict?

#1258491

I can make a copy of the site using the Duplicator plugin:
https://wordpress.org/plugins/duplicator/

can you deploy this copy without knowing the admin password?

#1259183

Hi, Nigel!

I found the cause of this error!

The cause of the error in this JS code:

<script>
jQuery( document ).ready( function($) {
	$( 'a' ).click( function() {
		if ( this.href ) {
			if ( this.href.indexOf( 'mydomain.com' ) < 0 ) {
				$( this ).attr( 'target', '_blank' );
			} else {
				$( this ).attr( 'target', '_self' );
			}
		}
	});
});
</script>

This code is used to open links to external sites in a new browser tab.

Tell me, please, how to modify this code so that it does not conflict with Toolset?

Thanks!

#1259849

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

OK, yes, that would be the problem. You are using that code as a very blunt instrument to modify all href attributes across the entire site.

A delete post link includes important details in the target attribute, and your code is wiping it out.

Here's an example:

<a href="<em><u>hidden link</u></em>" class="cred-refresh-after-delete" id="_cred_cred_144_1" target="_cred_cred_144_1_iframe" onclick="return _cred_cred_delete_post_handler(true, this, false, false, "Are you sure you want to delete this post?", 1);">Delete Second</a>

Whoever wrote your code will have to modify it so that it doesn't break links which already have a target set that is not _blank or _self.

I'm sorry but we cannot write or edit custom code for you.

#1260113
sc6.png

Well, with your hint, we can fix the JS code yourself.

Thanks for the help!

It turned out very cool! Together with the delete buttons, I added the add form at the bottom of the page (see screenshot).

#1260123

My issue is resolved now. Thank you!