Home › Forums › Feature Requests › add Remove Field Confirmation Dialog
Hi there
It would be great (IMO) to have functions to prevent removing fields/layouts by accident (in Repeater Field / Flexible Content Fields).
It happens quite often that users accidentally remove fields/layouts by clicking the minus icon (-), with the intent to collapse a row. But of course the entire field gets removed then. Hm.
To prevent that, I’d love to see some kind of a confirmation dialog or double click scenario before a field/layout gets removed.
Alternatively or additionally, an UNDO function would serve the same purpose.
// Just an idea to make the best plugin even better 🙂
I’ve posted this request on the github issues board. So your request is known by the developer
Hi @kitt
Thanks for the feature request.
I can add in a setting to allow a confirmation popup. Leave it with me and I’ll have a think about the best way to add this in
Hi @kitt
I’ve done some testing with this idea and think it will be best to leave as a snippet of code instead of merging into the core.
You can use it like so:
<?php
add_action('acf/input/admin_head', 'my_acf_admin_head');
function my_acf_admin_head() {
?>
<script type="text/javascript">
(function($) {
acf.add_action('ready', function(){
$('body').on('click', '.acf-repeater-remove-row', function( e ){
return confirm("Delete row?");
});
});
})(jQuery);
</script>
<?php
}
?>
This will allow you to decline the prompt and prevent the click action from triggering ACF’s repeater remove function.
Thanks
E
Hi Guys,
This seems very useful.
To we have to add this code to the function.php?
Regards,
Franck
Tx. That’s what I tought. I use to have the blank page error because of my syntax. You cannot copy/paste this directly 😉
Now I would like to do the same but with a flxiebl field.
any ideas ?
Cheers.
Got it guys.
Here’s for a flexible field on
ACF Pro 5.3.2.2
add_action('acf/input/admin_head', 'my_acf_admin_head');
function my_acf_admin_head() {
?>
<script type="text/javascript">
(function($) {
acf.add_action('ready', function(){
$('body').on('click', 'li.acf-fc-show-on-hover a.acf-icon.-minus.small', function( e ){
return confirm("Do you really want to delete this?");
});
});
})(jQuery);
</script>
<?php
}
Hi!!
I know the topic has already been solved, but I’m looking for just that !! However, for my case it did not work. I inserted in the functions.php of my theme. That’s right??
add_action('acf/input/admin_head', 'my_acf_admin_head');
function my_acf_admin_head() {
?>
<script type="text/javascript">
(function($) {
acf.add_action('ready', function(){
$('body').on('click', '.acf-repeater .acf-row-handle .acf-icon.-minus', function( e ){
return confirm("Tem certeza que irá deletar este item?");
});
});
})(jQuery);
</script>
<?php
}
What am I doing wrong?
Thank you in advance.
The ACF class names changed and so you need to adjust that. This one works for me:
add_action('acf/input/admin_head', 'my_acf_admin_head_flex');
function my_acf_admin_head_flex() {
?>
<script type="text/javascript">
(function($) {
acf.add_action('ready', function(){
$('body').on('click', '.acf-fc-layout-controlls .acf-icon.-minus.small', function( e ){
return confirm("Tem certeza que irá deletar este item?");
});
});
})(jQuery);
</script>
<?php
}
The topic ‘add Remove Field Confirmation Dialog’ is closed to new replies.
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.