Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
I did, but the fields only get rendered after opening its corresponding fieldset, so just a timeout didn't cut it. I had to set a timeout for rendering the fieldsets and after they were set, set a listener for opening a specific fieldset to allow getting the data from the desired fields.
I think I found out what happens: apparently Magento 2 load all "fieldsets" on the admin pages, but doesn't load the underlying fields until clicked on the fieldset, that's why my js couldn't find the values, because they were not yet set. Now I'm checking if they are already set and if not, listen on the openining of the fieldset before trying again. What I want to do is be able to link CMS pages to other pages (which I got working), but exclude the current page from the list of selectable pages to link to.
So after some more messing around, I found it is not Ajax, the fields just don't get renered until you click the parent fieldset (open the fieldset). That makes things a bit difficult. I'm still trying to figure out how to go about this.
There's still a problem, the page seems to be rendered via Ajax I think, so whenever I try to log a value from one of the inputs from 'cms_page_form.xml' I get an undefined. How do I make it load after all form fields have rendered?
Sorry about the previous comment, it got cut of, here's the full comment: This works great for editing already existing CMS pages, but when I want to create a new CMS page, it throws the following error: Warning: Invalid argument supplied for foreach() in /var/www/app/code/Phpro/CmsRedirect/Plugin/Model/Page/DataProvider.php on line 25. It looks like somethiing was wrong wit the foreach ($result as &$item) {. To circumvent this I wrote a check around that to check if there is a $result and now it works great. Many, many thanks for the quick and elaborate response!