How to detect whether form controls exists for a pagetype?
Permalink
Hello team,
I have developed a package that includes a custom theme.
I am having issues whenever I update the package because form controls get added to my pagetype on every update resulting in duplicate controls.
I have managed to come up with a method that checks whether a control exists before adding it to the pagetype but it only works for built-in properties.
How can I detect custom attributes and block controls already added to the pagetype?
The addToPageTypeComposerFormLayoutSet always adds a control on each invocation hence the requirement to check for existence before calling the method.
See attached image for sample form controls
PS: I am adding the composer form controls programmatically.
Here's my method for determining if a control already exists (Using Concrete v5.8.3.2)
I have developed a package that includes a custom theme.
I am having issues whenever I update the package because form controls get added to my pagetype on every update resulting in duplicate controls.
I have managed to come up with a method that checks whether a control exists before adding it to the pagetype but it only works for built-in properties.
How can I detect custom attributes and block controls already added to the pagetype?
The addToPageTypeComposerFormLayoutSet always adds a control on each invocation hence the requirement to check for existence before calling the method.
See attached image for sample form controls
PS: I am adding the composer form controls programmatically.
Here's my method for determining if a control already exists (Using Concrete v5.8.3.2)
protected function getPageTypeFormControlProperty($pagetype, $control) { $sets = PageTypeComposerFormLayoutSet::getList($pagetype); foreach ($sets as $s) { $setControls = PageTypeComposerFormLayoutSetControl::getList($s); foreach ($setControls as $sc) { $cntr = $sc->getPageTypeComposerControlObject(); if ($cntr->getPageTypeComposerControlIdentifier() == $control->getPageTypeComposerControlIdentifier()) { //- $control->getPageTypeComposerControlTypeHandle() getPageTypeComposerFormLayoutSetControlObject //echo "We have it: $cntr->getPageTypeComposerControlIdentifier()"; $ctrl = $cntr; break; } } } return $ctrl;
Viewing 15 lines of 20 lines. View entire code block.