Skip to main content
Nico V's user avatar
Nico V's user avatar
Nico V's user avatar
Nico V
  • Member for 8 years, 1 month
  • Last seen more than 4 years ago
awarded
awarded
awarded
awarded
awarded
awarded
awarded
awarded
Loading…
Loading…
comment
Magento 2 : add custom JavaScript to CMS page create/edit in admin
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.
comment
Magento 2 : add custom JavaScript to CMS page create/edit in admin
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.
comment
Magento 2 : add custom JavaScript to CMS page create/edit in admin
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.
comment
Magento 2 : add custom JavaScript to CMS page create/edit in admin
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?
Loading…
awarded
Loading…
comment
Magento 2.1.7 add CMS page multiselect to CMS page
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/DataPr‌​ovider.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!
comment
Magento 2.1.7 add CMS page multiselect to CMS page
this works great for editing already existing CMS pages, but when I want to create a new CMS page, it throws the following error: