本文整理汇总了PHP中CustomFieldData类的典型用法代码示例。如果您正苦于以下问题:PHP CustomFieldData类的具体用法?PHP CustomFieldData怎么用?PHP CustomFieldData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CustomFieldData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCreateSourceValues
public function testCreateSourceValues()
{
$sourceValues = array('Word of Mouth', 'Outbound', 'Trade Show');
$sourceFieldData = CustomFieldData::getByName('LeadSources');
$sourceFieldData->serializedData = serialize($sourceValues);
$this->assertTrue($sourceFieldData->save());
}
示例2: testLogAuditForOwnedMultipleValuesCustomField
public function testLogAuditForOwnedMultipleValuesCustomField()
{
Yii::app()->user->userModel = User::getByUsername('jimmy');
$beforeCount = AuditEvent::getCount();
$values = array('A', 'B', 'C', 'CC', 'CCC');
$customFieldData = CustomFieldData::getByName('MultipleIndustries');
$customFieldData->serializedData = serialize($values);
$saved = $customFieldData->save();
$this->assertTrue($saved);
$model = new TestOwnedCustomFieldsModel();
$this->assertTrue($model->save());
$this->assertEquals($beforeCount + 1, AuditEvent::getCount());
$model = TestOwnedCustomFieldsModel::getById($model->id);
$value = new CustomFieldValue();
$value->value = 'C';
$model->multipleIndustries->values->removeAll();
//To remove the blank CustomFieldValue. This mimics
//setValues($values) in MultipleValuesCustomField.
$model->multipleIndustries->values->add($value);
$this->assertTrue($model->save());
$this->assertEquals($beforeCount + 2, AuditEvent::getCount());
$model = TestOwnedCustomFieldsModel::getById($model->id);
$value = new CustomFieldValue();
$value->value = 'B';
$model->multipleIndustries->values->add($value);
$this->assertTrue($model->save());
$this->assertEquals($beforeCount + 3, AuditEvent::getCount());
$AuditEventsList = AuditEvent::getTailEvents(3);
$this->assertRegExp('/[0-9]+\\/[0-9]+\\/[0-9]+ [0-9]+:[0-9]+ [AP]M, ' . 'James Boondog, Item Created, ' . 'TestOwnedCustomFieldsModel\\([0-9]+\\), \\(None\\)/', ZurmoModule::stringifyAuditEvent($AuditEventsList[0]));
$this->assertRegExp('/[0-9]+\\/[0-9]+\\/[0-9]+ [0-9]+:[0-9]+ [AP]M, ' . 'James Boondog, Item Modified, ' . 'TestOwnedCustomFieldsModel\\([0-9]+\\), \\(None\\), ' . 'Changed Multiple Industries Values from to C/', ZurmoModule::stringifyAuditEvent($AuditEventsList[1]));
$this->assertRegExp('/[0-9]+\\/[0-9]+\\/[0-9]+ [0-9]+:[0-9]+ [AP]M, ' . 'James Boondog, Item Modified, ' . 'TestOwnedCustomFieldsModel\\([0-9]+\\), \\(None\\), ' . 'Changed Multiple Industries Values from C to C, B/', ZurmoModule::stringifyAuditEvent($AuditEventsList[2]));
}
示例3: testLoad
public function testLoad()
{
$customFieldData = CustomFieldData::getByName('Titles');
$this->assertEquals(0, count(unserialize($customFieldData->serializedData)));
$customFieldData = CustomFieldData::getByName('AccountTypes');
$this->assertEquals(0, count(unserialize($customFieldData->serializedData)));
$customFieldData = CustomFieldData::getByName('LeadSources');
$this->assertEquals(0, count(unserialize($customFieldData->serializedData)));
$customFieldData = CustomFieldData::getByName('Industries');
$this->assertEquals(0, count(unserialize($customFieldData->serializedData)));
$customFieldData = CustomFieldData::getByName('MeetingCategories');
$this->assertEquals(0, count(unserialize($customFieldData->serializedData)));
$this->assertEquals(0, ContactState::getCount());
// do a getAll to ensure we create base currency
$baseCurrency = Currency::getAll();
$this->assertCount(1, $baseCurrency);
$this->assertEquals(1, Currency::getCount());
$messageLogger = new MessageLogger();
DefaultDataUtil::load($messageLogger);
$customFieldData = CustomFieldData::getByName('Titles');
$this->assertEquals(4, count(unserialize($customFieldData->serializedData)));
$customFieldData = CustomFieldData::getByName('AccountTypes');
$this->assertEquals(3, count(unserialize($customFieldData->serializedData)));
$customFieldData = CustomFieldData::getByName('LeadSources');
$this->assertEquals(4, count(unserialize($customFieldData->serializedData)));
$customFieldData = CustomFieldData::getByName('Industries');
$this->assertEquals(9, count(unserialize($customFieldData->serializedData)));
$customFieldData = CustomFieldData::getByName('MeetingCategories');
$this->assertEquals(2, count(unserialize($customFieldData->serializedData)));
$this->assertEquals(6, ContactState::getCount());
$this->assertEquals(1, Currency::getCount());
}
示例4: renderControlEditable
/**
* Render a hidden input, a text input with an auto-complete
* event, and a select button. These three items together
* form the Opportunity Editable Element
* @return The element's content as a string.
*/
protected function renderControlEditable()
{
$content = null;
$content .= ZurmoHtml::textField('stageToProbabilityMapping_notUsed', null, array('id' => $this->getEditableInputId(), 'style' => "display:none;"));
$fieldData = CustomFieldData::getByName('SalesStages');
if ($fieldData->serializedData != null) {
$values = unserialize($fieldData->serializedData);
if (!is_array($values)) {
$values = array();
}
} else {
$values = array();
}
$stagesToProbabilities = OpportunitiesModule::getStageToProbabilityMappingData();
foreach ($values as $value) {
if (isset($stagesToProbabilities[$value])) {
$probability = $stagesToProbabilities[$value];
} else {
$probability = 0;
}
$htmlOptions = array('name' => $this->getNameForInputField($value), 'value' => $probability);
$element = $this->form->textField($this->model, $this->attribute, $htmlOptions);
$element .= ZurmoHtml::tag('span', array(), $value);
$content .= ZurmoHtml::tag('div', array('class' => 'has-lang-label'), $element);
}
return $content;
}
示例5: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
SecurityTestHelper::createSuperAdmin();
ContactsModule::loadStartingData();
//Need to instantiate a controller so the clipWidget can work properly in elements that utilize it.
$controller = Yii::app()->createController('reports/default');
list($controller, $actionId) = $controller;
Yii::app()->setController($controller);
$values = array('Test1', 'Test2', 'Test3', 'Sample', 'Demo');
$customFieldData = CustomFieldData::getByName('ReportTestDropDown');
$customFieldData->serializedData = serialize($values);
$saved = $customFieldData->save();
assert($saved);
// Not Coding Standard
$values = array('Multi 1', 'Multi 2', 'Multi 3');
$customFieldData = CustomFieldData::getByName('ReportTestMultiDropDown');
$customFieldData->serializedData = serialize($values);
$saved = $customFieldData->save();
assert($saved);
// Not Coding Standard
$values = array('Radio 1', 'Radio 2', 'Radio 3');
$customFieldData = CustomFieldData::getByName('ReportTestRadioDropDown');
$customFieldData->serializedData = serialize($values);
$saved = $customFieldData->save();
assert($saved);
// Not Coding Standard
$values = array('Cloud 1', 'Cloud 2', 'Cloud 3');
$customFieldData = CustomFieldData::getByName('ReportTestTagCloud');
$customFieldData->serializedData = serialize($values);
$saved = $customFieldData->save();
assert($saved);
// Not Coding Standard
}
示例6: makeDropDownAttributeUsingAdapter
public static function makeDropDownAttributeUsingAdapter($namePrefix, $valuesPrefix, RedBeanModel $modelTouse)
{
$values = array($valuesPrefix . '1', $valuesPrefix . '2', $valuesPrefix . '3', $valuesPrefix . '4');
$labels = array('fr' => array($valuesPrefix . '1 fr', $valuesPrefix . '1 fr', $valuesPrefix . '1 fr', $valuesPrefix . '1 fr'), 'de' => array($valuesPrefix . '1 de', $valuesPrefix . '1 de', $valuesPrefix . '1 de', $valuesPrefix . '1 de'));
$airplanesFieldData = CustomFieldData::getByName($namePrefix . 'TheData');
$airplanesFieldData->serializedData = serialize($values);
$saved = $airplanesFieldData->save();
if (!$saved) {
throw new NotSupportedException();
}
$attributeForm = new DropDownAttributeForm();
$attributeForm->attributeName = $namePrefix;
$attributeForm->attributeLabels = array('de' => $namePrefix . ' de', 'en' => $namePrefix . ' en', 'es' => $namePrefix . ' es', 'fr' => $namePrefix . ' fr', 'it' => $namePrefix . ' it');
$attributeForm->isAudited = false;
$attributeForm->isRequired = false;
$attributeForm->defaultValueOrder = null;
$attributeForm->customFieldDataData = $values;
$attributeForm->customFieldDataName = $namePrefix . 'TheData';
$attributeForm->customFieldDataLabels = $labels;
$modelAttributesAdapterClassName = $attributeForm::getModelAttributeAdapterNameForSavingAttributeFormData();
$adapter = new $modelAttributesAdapterClassName($modelTouse);
try {
$adapter->setAttributeMetadataFromForm($attributeForm);
} catch (FailedDatabaseSchemaChangeException $e) {
echo $e->getMessage();
throw new NotSupportedException();
}
}
示例7: testGetExportValue
public function testGetExportValue()
{
$values = array('Test1', 'Test2', 'Test3', 'Sample', 'Demo');
$customFieldData = CustomFieldData::getByName('ExportTestRadioDropDown');
$customFieldData->serializedData = serialize($values);
$saved = $customFieldData->save();
$this->assertTrue($saved);
$data = array();
$model = new ExportTestModelItem();
$model->radioDropDown->value = $values[1];
$model->lastName = "Smith";
$model->string = "Some Test String";
// We have to save model, to get correct currencyValue id.
$this->assertTrue($model->save());
$adapter = new RadioDropDownRedBeanModelAttributeValueToExportValueAdapter($model, 'radioDropDown');
$adapter->resolveData($data);
$compareData = array('Test2');
$this->assertEquals($compareData, $data);
$data = array();
$adapter->resolveHeaderData($data);
$compareData = array($model->getAttributeLabel('radioDropDown'));
$this->assertEquals($compareData, $data);
$data = array();
$model = new ExportTestModelItem();
$adapter = new RadioDropDownRedBeanModelAttributeValueToExportValueAdapter($model, 'radioDropDown');
$adapter->resolveData($data);
$compareData = array('');
$this->assertEquals($compareData, $data);
$data = array();
$adapter->resolveHeaderData($data);
$compareData = array($model->getAttributeLabel('radioDropDown'));
$this->assertEquals($compareData, $data);
}
开发者ID:youprofit,项目名称:Zurmo,代码行数:33,代码来源:RadioDropDownRedBeanModelAttributeValueToExportValueAdapterTest.php
示例8: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
$super = User::getByUsername('super');
$bobby = UserTestHelper::createBasicUser('bobby');
$sarah = UserTestHelper::createBasicUser('sarah');
self::$superUserId = $super->id;
self::$bobbyUserId = $bobby->id;
self::$sarahUserId = $sarah->id;
$currency = Currency::makeBaseCurrency();
assert($currency->code == 'USD');
// Not Coding Standard
self::$baseCurrencyId = $currency->id;
$currency = new Currency();
$currency->code = 'EUR';
$currency->rateToBase = 2;
assert($currency->save());
// Not Coding Standard
self::$eurCurrencyId = $currency->id;
$values = array('A1', 'B2', 'C3', 'D4', 'E5', 'F6');
$fieldData = CustomFieldData::getByName('WorkflowTestDropDown');
$fieldData->serializedData = serialize($values);
$saved = $fieldData->save();
assert($saved);
// Not Coding Standard
$values = array('A1', 'B2', 'C3', 'D4', 'E5', 'F6');
$fieldData = CustomFieldData::getByName('WorkflowTestRadioDropDown');
$fieldData->serializedData = serialize($values);
$saved = $fieldData->save();
assert($saved);
// Not Coding Standard
$values = array('M1', 'M2', 'M3', 'M4', 'M5', 'M6');
$fieldData = CustomFieldData::getByName('WorkflowTestMultiDropDown');
$fieldData->serializedData = serialize($values);
$saved = $fieldData->save();
assert($saved);
// Not Coding Standard
$values = array('M1', 'M2', 'M3', 'M4', 'M5', 'M6');
$fieldData = CustomFieldData::getByName('WorkflowTestTagCloud');
$fieldData->serializedData = serialize($values);
$saved = $fieldData->save();
assert($saved);
// Not Coding Standard
$loaded = ContactsModule::loadStartingData();
assert($loaded);
// Not Coding Standard
$contactStates = ContactState::getByName('New');
self::$newState = $contactStates[0];
$contactStates = ContactState::getByName('In progress');
self::$inProgressState = $contactStates[0];
self::$groupTest = new Group();
self::$groupTest->name = 'test';
$saved = self::$groupTest->save();
assert($saved);
// Not Coding Standard
$group = Group::getByName(Group::EVERYONE_GROUP_NAME);
$saved = $group->save();
assert($saved);
// Not Coding Standard
}
示例9: getStageDropDownArray
/**
* Gets array for stages
* @return array
*/
protected function getStageDropDownArray()
{
$customFieldData = CustomFieldData::getByName('ProductStages');
$customFieldIndexedData = CustomFieldDataUtil::getDataIndexedByDataAndTranslatedLabelsByLanguage($customFieldData, Yii::app()->language);
$data = array_merge(array(ProductsConfigurationForm::FILTERED_BY_ALL_STAGES => Zurmo::t('Core', 'All')), $customFieldIndexedData);
return $data;
}
示例10: testConstructIncompleteIsNotNeeded
/**
* There previously was a problem with a model being created, then a new custom field added, then if you try
* to access the available CustomFieldData it was not available on that model. Since performance3 work
* this has been resolve and this test confirms it works ok
*/
public function testConstructIncompleteIsNotNeeded()
{
//First create AAA model and save
$aaa = new AAA();
$aaa->aaaMember = 'test';
$saved = $aaa->save();
$this->assertTrue($saved);
$aaaId = $aaa->id;
$aaa->forget();
unset($aaa);
//Second create customFieldData
$values = array('Item 1', 'Item 2', 'Item 3');
$labels = array('fr' => 'Item 1 fr', 'fr' => 'Item 2 fr', 'fr' => 'Item 3 fr');
$customFieldData = CustomFieldData::getByName('Items');
$customFieldData->serializedData = serialize($values);
$customFieldData->serializedLabels = serialize($labels);
$this->assertTrue($customFieldData->save());
$id = $customFieldData->id;
unset($customFieldData);
//Third create a CustomField on AAA
$metadata = AAA::getMetadata();
$metadata['AAA']['customFields']['newCustomField'] = 'Items';
$metadata['AAA']['relations']['newCustomField'] = array(RedBeanModel::HAS_ONE, 'CustomField');
AAA::setMetadata($metadata);
//Fourth make sure AAA can utilize CustomFieldData after being constructed
$aaa = AAA::GetById($aaaId);
$this->assertTrue($aaa->isAnAttribute('newCustomField'));
$dropDownArray = unserialize($aaa->newCustomField->data->serializedData);
$this->assertCount(3, $dropDownArray);
//Fifth make sure a new model has the data available
$aaa = new AAA();
$this->assertTrue($aaa->isAnAttribute('newCustomField'));
$dropDownArray = unserialize($aaa->newCustomField->data->serializedData);
$this->assertCount(3, $dropDownArray);
}
示例11: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
$super = SecurityTestHelper::createSuperAdmin();
Yii::app()->user->userModel = $super;
$jim = UserTestHelper::createBasicUser('jim');
$values = array('Test1', 'Test2', 'Test3', 'Sample', 'Demo');
$customFieldData = CustomFieldData::getByName('ImportTestDropDown');
$customFieldData->serializedData = serialize($values);
$saved = $customFieldData->save();
assert($saved);
// Not Coding Standard
$values = array('Multi 1', 'Multi 2', 'Multi 3');
$customFieldData = CustomFieldData::getByName('ImportTestMultiDropDown');
$customFieldData->serializedData = serialize($values);
$saved = $customFieldData->save();
assert($saved);
// Not Coding Standard
$values = array('Cloud 1', 'Cloud 2', 'Cloud 3');
$customFieldData = CustomFieldData::getByName('ImportTestTagCloud');
$customFieldData->serializedData = serialize($values);
$saved = $customFieldData->save();
assert($saved);
// Not Coding Standard
//Ensure the external system id column is present.
$userTableName = User::getTableName();
ExternalSystemIdUtil::addExternalIdColumnIfMissing($userTableName);
ExternalSystemIdUtil::updateByModel($super, 'A');
ExternalSystemIdUtil::updateByModel($jim, 'B');
ExternalSystemIdUtil::addExternalIdColumnIfMissing(ImportModelTestItem::getTableName());
ExternalSystemIdUtil::addExternalIdColumnIfMissing(ImportModelTestItem2::getTableName());
ExternalSystemIdUtil::addExternalIdColumnIfMissing(ImportModelTestItem3::getTableName());
ExternalSystemIdUtil::addExternalIdColumnIfMissing(ImportModelTestItem4::getTableName());
}
示例12: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
$super = SecurityTestHelper::createSuperAdmin();
Yii::app()->user->userModel = $super;
$jim = UserTestHelper::createBasicUser('jim');
$values = array('Test1', 'Test2', 'Test3', 'Sample', 'Demo');
$customFieldData = CustomFieldData::getByName('ImportTestDropDown');
$customFieldData->serializedData = serialize($values);
$saved = $customFieldData->save();
assert($saved);
// Not Coding Standard
$values = array('Multi 1', 'Multi 2', 'Multi 3');
$customFieldData = CustomFieldData::getByName('ImportTestMultiDropDown');
$customFieldData->serializedData = serialize($values);
$saved = $customFieldData->save();
assert($saved);
// Not Coding Standard
$values = array('Cloud 1', 'Cloud 2', 'Cloud 3');
$customFieldData = CustomFieldData::getByName('ImportTestTagCloud');
$customFieldData->serializedData = serialize($values);
$saved = $customFieldData->save();
assert($saved);
// Not Coding Standard
//Ensure the external system id column is present.
$columnName = ExternalSystemIdUtil::EXTERNAL_SYSTEM_ID_COLUMN_NAME;
RedBeanColumnTypeOptimizer::externalIdColumn(User::getTableName('User'), $columnName);
$userTableName = User::getTableName('User');
R::exec("update " . $userTableName . " set {$columnName} = 'A' where id = {$super->id}");
R::exec("update " . $userTableName . " set {$columnName} = 'B' where id = {$jim->id}");
RedBeanColumnTypeOptimizer::externalIdColumn(ImportModelTestItem::getTableName('ImportModelTestItem'), $columnName);
RedBeanColumnTypeOptimizer::externalIdColumn(ImportModelTestItem2::getTableName('ImportModelTestItem2'), $columnName);
RedBeanColumnTypeOptimizer::externalIdColumn(ImportModelTestItem3::getTableName('ImportModelTestItem3'), $columnName);
RedBeanColumnTypeOptimizer::externalIdColumn(ImportModelTestItem4::getTableName('ImportModelTestItem4'), $columnName);
}
示例13: resolveStageDefaultValue
/**
* Resolve stage default value
* @param RedBeanModel $product
* @return string
*/
public function resolveStageDefaultValue($product)
{
$customFieldData = CustomFieldData::getByName('ProductStages');
$dropDownArray = unserialize($customFieldData->serializedData);
if ($product->stage->value == null) {
$product->stage->value = $dropDownArray[0];
}
}
示例14: getTypeValues
public static function getTypeValues()
{
$values = array('Prospect', 'Customer', 'Vendor');
$typeFieldData = CustomFieldData::getByName('AccountTypes');
$typeFieldData->serializedData = serialize($values);
assert($typeFieldData->save());
// Not Coding Standard
return $values;
}
示例15: createCategories
public static function createCategories()
{
$values = array('Meeting', 'Call', 'Event');
$typeFieldData = CustomFieldData::getByName('MeetingCategories');
$typeFieldData->serializedData = serialize($values);
$saved = $typeFieldData->save();
if (!$saved) {
throw new NotSupportedException();
}
}