This topic contains 1 reply, has 2 voices, and was last updated by Mike Kudelya 6 years, 10 months ago.
- Topic
Hi all,
I’ve created a migration class inside a bundle for creating custom fields for the Contact entity. It executed properly, the fields were added along with their correct data types, and the fixtures for the select and multi-select fields were loaded as well.
However, when I view the custom fields that were added using the migration in OroCRM Admin, the Label field is empty, and when I try to fill it with a value and save it, it still remains blank. Any idea what could have happened? Here’s my migration class:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081class AddCustomContactFieldsMigration implements Migration, ExtendExtensionAwareInterface {/*** @var ExtendExtension*/protected $extendExtension;public function setExtendExtension(ExtendExtension $extendExtension) {$this->extendExtension = $extendExtension;}public function up(Schema $schema, QueryBag $queries) {$table = $schema->getTable('orocrm_contact');// data: []$fields = Yaml::parse(file_get_contents(__DIR__ . '/dictionary/custom-fields.yml'));// $field = ['name' => '', 'dataType' => 'Multi-Select', 'label' => '']foreach ($fields['data'] as $field) {$field = (object) $field;$isSelect = in_array($field->dataType, ['Select', 'Multi-Select']);$fieldName = $isSelect ? $field->name . ($field->dataType == 'Select' ? '_id' : '_ss') : $field->name;if (!$table->hasColumn($fieldName)) {if ($isSelect) {$this->addSelect($field, $schema, $table);} else {$this->addColumn($field, $table);}}}}/*** Function for adding a field with simple data type** @param Object $field* @param Table $table*/private function addColumn($field, $table) {$table->addColumn($field->name,strtolower($field->dataType),['oro_options' => ['entity' => ['label' => $field->label,'description' => $field->label],'extend' => ['owner' => ExtendScope::OWNER_CUSTOM],'datagrid' => ['is_visible' => false],'merge' => ['display' => true]]]);}/*** Function for adding a select/multi-select field** @param Object $field* @param Schema $schema* @param Table $table*/private function addSelect($field, Schema $schema, Table $table) {$isMulti = $field->dataType == 'Multi-Select';$this->extendExtension->addEnumField($schema,$table,$field->name,ExtendHelper::buildEnumCode($field->name),$isMulti,true,['entity' => ['label' => $field->label,'description' => $field->label],'extend' => ['owner' => ExtendScope::OWNER_CUSTOM]]);}}
The forum ‘OroCRM – Programming Questions’ is closed to new topics and replies.