This topic contains 8 replies, has 3 voices, and was last updated by acaliman 6 years, 5 months ago.
- Topic
I am trying to create a link between addresses and acounts on or CRM 2.
So I added 2 fields with a migration, “shipping address” and “billing address”.12345678910111213141516171819202122232425262728293031323334353637383940414243444546$table->addColumn('shipping_address_id','integer',['notnull' => false,'oro_options' => ['extend' => ['is_extended' => true,'owner' => ExtendScope::OWNER_CUSTOM,],'datagrid' => ['is_visible' => true],'entity' => ['label' => 'Shipping address'],]]);$table->addColumn('billing_address_id','integer',['notnull' => false,'oro_options' => ['extend' => ['is_extended' => true,'owner' => ExtendScope::OWNER_CUSTOM,],'datagrid' => ['is_visible' => true],'entity' => ['label' => 'Billing address'],]]);$table->addIndex(['shipping_address_id'], 'IDX_7166D3714D4CFF2B', []);$table->addIndex(['billing_address_id'], 'IDX_7166D37179D0C0E4', []);$table->addForeignKeyConstraint($schema->getTable('oro_address'),['shipping_address_id'],['id'],['onDelete' => 'SET NULL', 'onUpdate' => null]);$table->addForeignKeyConstraint($schema->getTable('oro_address'),['billing_address_id'],['id'],['onDelete' => 'SET NULL', 'onUpdate' => null]);I also added the following code in account/update.html.twig
12345678910111213{% set dataBlocks = dataBlocks|merge( [{'title' : 'Addresses'|trans,'subblocks': [{'title': 'oro.account.billing_address_id.label'|trans,'data': [form_widget(form.billing_address_id)]},{'title': 'oro.account.shipping_address_id.label'|trans,'data': [form_widget(form.shipping_address_id)]},]}] ) %}I also added the following code in form/type/accountType.php
1234567891011121314151617181920$builder->add('shipping_address_id',//shippingAddress'oro_address',['required' => false]);$builder->add('billing_address_id',//billingAddress'oro_address',['required' => false]);$this->propertyAccessor = new PropertyAccessor();$builder->addModelTransformer(new AddressSameTransformer($this->propertyAccessor,['billing_address_id', 'shipping_address_id']));I can now see an “address” block in the edit view, and I twice get a form to enter the address in: perfect!
The only problem is, that when I save I get the error I get the message “This value should contain only numbers.”
I assume I did something wrong with my migration and should have used a different type than “integer”, but I do not know what.
Can somebody please help me?
The forum ‘OroPlatform – How do I? Questions’ is closed to new topics and replies.