public function testGetSetAndMethods() { $availableCustomFieldAttributes = array('a', 'test', 'b'); $mappingData = array('Item 1' => 'parentItem1', 'Item2' => null); $customFieldData = CustomFieldData::getByName('Items'); $mapping = new DropDownDependencyCustomFieldMapping(3, 'test', $availableCustomFieldAttributes, $customFieldData, $mappingData); $this->assertEquals(true, $mapping->allowsAttributeSelection()); $mapping->doNotAllowAttributeSelection(); $this->assertEquals(false, $mapping->allowsAttributeSelection()); $this->assertEquals('Level: 4', $mapping->getTitle()); $this->assertEquals(3, $mapping->getPosition()); $this->assertEquals('test', $mapping->getAttributeName()); $this->assertEquals($availableCustomFieldAttributes, $mapping->getAvailableCustomFieldAttributes()); $this->assertEquals('First select level 3', $mapping->getSelectHigherLevelFirstMessage()); $this->assertEquals($customFieldData, $mapping->getCustomFieldData()); $this->assertEquals('parentItem1', $mapping->getMappingDataSelectedParentValueByValue('Item 1')); $this->assertEquals(null, $mapping->getMappingDataSelectedParentValueByValue('Item 2')); }
protected function renderAttributeNameSelectionContent(DropDownDependencyCustomFieldMapping $mapping) { $inputName = $this->formName . '[mappingData][' . $mapping->getPosition() . '][attributeName]'; $inputId = ZurmoHtml::getIdByName($inputName); $htmlOptions = array(); $htmlOptions['id'] = $inputId; if ($mapping->allowsAttributeSelection()) { $htmlOptions['empty'] = Zurmo::t('Core', '(None)'); $data = $mapping->getAvailableCustomFieldAttributes(); } else { $htmlOptions['empty'] = $mapping->getSelectHigherLevelFirstMessage(); $data = array(); } Yii::app()->clientScript->registerScript('DropDownDependency' . $inputId, $this->renderAttributeDropDownOnChangeScript($inputId)); $content = ZurmoHtml::dropDownList($inputName, $mapping->getAttributeName(), $data, $htmlOptions); return $content; }