Home › Forums › Add-ons › Repeater Field › TypeError: 'undefined' is not an object
I’m using the Repeater plugin and I can’t remove/add sub fields anymore because of this JavaScript error:
TypeError: ‘undefined’ is not an object (evaluating ‘this.toolbars[this.o.toolbar]’) in “input.min.js?ver=4.3.4”
Hi @Till
Thanks for the bug report. The full line is:
if( acf.helpers.isset( this.toolbars[ this.o.toolbar ] ) )
And it looks like the isset function is not working as per expected.
Is it possible that your WYSIWYG field contains a ‘toolbar’ setting that does not exist anymore?
Thanks
E
That’s the PHP config that creates the field: http://pastebin.com/E2SPCWbC — Anything wrong with it?
Hi @Till
There is nothing wrong with the linked PHP, however the issue could be stemming from another field group.
Are you able to debug the JS?
1. Copy the contents from js/input.js
2. Replace the contents of js/input.min.js
3. Find the line with if( acf.helpers.isset( this.toolbars[ this.o.toolbar ] ) )
3. Before this line, console.log the variables such as this.o.toolbar
Thanks
E
Sure! See below. Need anything else?
this.toolbars
: undefined
this.o
:
{
id: "wysiwyg-acf-field-field_52ba5d6289438_0_field_52ba64a564a1b-52fd8bc9b44f6"
toolbar: "full"
upload: "no"
__proto__: Object
}
Hi @Till
Thanks for the info.
For some reason, your toolbars are not being added to the wysiwyg
JS object. Normally, an array of toolbars will exist at acf.fields.wysiwyg.toolbars
(this.toolbars
).
On line 115 of core/controllers/input.php
you will see:
acf.fields.wysiwyg.toolbars = <?php echo json_encode( $t ); ?>;
It is possible that this line of script is not being run due to a JS error on the page. Can you check for any JS errors?
Perhaps also do some PHP debugging to make sure line 115 is correct data?
Thanks
E
Heya!
This is the output:
acf.fields.wysiwyg.toolbars = {
"full": {
"theme_advanced_buttons1": "bold,italic,strikethrough,bullist,numlist,blockquote,justifyleft,justifycenter,justifyright,link,unlink,wp_more,AtD,fullscreen,wp_adv",
"theme_advanced_buttons2": "formatselect,underline,justifyfull,forecolor,pasteword,removeformat,charmap,outdent,indent,undo,redo,wp_help,code",
"theme_advanced_buttons3": "",
"theme_advanced_buttons4": ""
},
"basic": {
"theme_advanced_buttons1": "bold,italic,underline,blockquote,strikethrough,bullist,numlist,justifyleft,justifycenter,justifyright,undo,redo,link,unlink,fullscreen"
}
};
Hi @Till
Your results show the correct data… I don’t understand why toolbars would be undefined…
Chances are you have some conflicting JS in a plugin or theme which is modifying the ACF object.
Are you able to install a fresh WP and, one by one, install your plugins / theme to see when the issue begins?
Thanks
E
It’s happening with all plugins disabled as well, even if I remove the wysiwyg sub-field, but without js errors. I’ll do some debugging in the next few days and get back to you.
I just figured it out. I was messing with the acf/helpers/get_dir
filter and the repeater input.js was never loaded… doh!
The topic ‘TypeError: 'undefined' is not an object’ 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.