/** * Creating new field, account, contact with filled custom field, relationship between them */ public function setUp() { SugarTestHelper::setUp('beanList'); SugarTestHelper::setUp('beanFiles'); SugarTestHelper::setUp('current_user', array(true, true)); $this->field = get_widget('varchar'); $this->field->id = 'Contactstest_c'; $this->field->name = 'test_c'; $this->field->type = 'varchar'; $this->field->len = 255; $this->field->importable = 'true'; $this->field->label = ''; $this->module = new Contact(); $this->dynamicField = new DynamicField('Contacts'); $this->dynamicField->setup($this->module); $this->dynamicField->addFieldObject($this->field); SugarTestHelper::setUp('dictionary'); $GLOBALS['reload_vardefs'] = true; $this->account = SugarTestAccountUtilities::createAccount(); $this->contact = SugarTestContactUtilities::createContact(); $this->contact->account_id = $this->account->id; $this->contact->test_c = 'test value'; $this->contact->load_relationship('accounts'); $this->contact->accounts->add($this->account->id); $this->contact->save(); $GLOBALS['db']->commit(); }
/** * save * * This function says the field template by calling the DynamicField addFieldObject function. It then * checks to see if updates are needed for the SearchFields.php file. In the event that the unified_search * member variable is set to true, a search field definition is updated/created to the SearchFields.php file. * * @param DynamicField $df */ function save($df) { // $GLOBALS['log']->debug('saving field: '.print_r($this,true)); $df->addFieldObject($this); require_once 'modules/ModuleBuilder/parsers/parser.searchfields.php'; $searchFieldParser = new ParserSearchFields($df->getModuleName(), $df->getPackageName()); //If unified_search is enabled for this field, then create the SearchFields entry $fieldName = $this->get_field_name($df->getModuleName(), $this->name); if ($this->unified_search && !isset($searchFieldParser->searchFields[$df->getModuleName()][$fieldName])) { $searchFieldParser->addSearchField($fieldName, array('query_type' => 'default')); $searchFieldParser->saveSearchFields($searchFieldParser->searchFields); } }