public function testGetAttributes() { $contactWebForm = new ContactWebForm(); $allAttributes = ContactWebFormsUtil::getAllAttributes(); $this->assertNotEmpty($allAttributes); $placedAttributes = ContactWebFormsUtil::getPlacedAttributes($contactWebForm); $nonPlacedAttributes = ContactWebFormsUtil::getNonPlacedAttributes($contactWebForm); $this->assertTrue(count($placedAttributes) < count($nonPlacedAttributes)); }
/** * @return string * @throws NotSupportedException */ protected function renderControlNonEditable() { if (isset($this->model->serializedData)) { $placedAttributes = ContactWebFormsUtil::getPlacedAttributes($this->model); $content = ''; foreach ($placedAttributes as $attribute) { $content .= $attribute['attributeLabel'] . '<br/>'; } return $content; } else { throw new NotSupportedException(); } }
public static function getMetadataByWebForm(ContactWebForm $contactWebForm) { assert('$contactWebForm instanceof ContactWebForm'); $contactWebFormAttributes = array_keys(ContactWebFormsUtil::getPlacedAttributes($contactWebForm)); $contactWebFormAttributes = ContactWebFormsUtil::excludeHiddenAttributes($contactWebForm, $contactWebFormAttributes); $viewClassName = 'ContactExternalEditAndDetailsView'; $moduleClassName = 'ContactsModule'; $modelClassName = $moduleClassName::getPrimaryModelName(); $editableMetadata = $viewClassName::getMetadata(); $designerRules = new EditAndDetailsViewDesignerRules(); $modelAttributesAdapter = DesignerModelToViewUtil::getModelAttributesAdapter($viewClassName, $modelClassName); $derivedAttributesAdapter = new DerivedAttributesAdapter($modelClassName); $attributeCollection = array_merge($modelAttributesAdapter->getAttributes(), $derivedAttributesAdapter->getAttributes()); $attributesLayoutAdapter = AttributesLayoutAdapterUtil::makeAttributesLayoutAdapter($attributeCollection, $designerRules, $editableMetadata); $layoutMetadataAdapter = new LayoutMetadataAdapter($viewClassName, $moduleClassName, $editableMetadata, $designerRules, $attributesLayoutAdapter->getPlaceableLayoutAttributes(), $attributesLayoutAdapter->getRequiredDerivedLayoutAttributeTypes()); $metadata = $layoutMetadataAdapter->resolveMetadataFromSelectedListAttributes($viewClassName, $contactWebFormAttributes); foreach ($metadata['global']['panels'][0]['rows'] as $index => $data) { if ($data['cells'][0]['elements'][0]['type'] == 'EmailAddressInformation') { $metadata['global']['panels'][0]['rows'][$index]['cells'][0]['elements'][0]['hideOptOut'] = true; } if ($data['cells'][0]['elements'][0]['type'] == 'TagCloud') { $metadata['global']['panels'][0]['rows'][$index]['cells'][0]['elements'][0]['type'] = 'MultiSelectDropDown'; } } return $metadata; }