OroAddressBundle provides PHP/REST/SOAP API for address CRUD operations.
<?php
//Accessing address manager from controller
/** @var $addressManager \Oro\Bundle\AddressBundle\Entity\Manager\AddressManager */
$addressManager = $this->get('oro_address.address.provider')->getStorage();
//create empty address entity
$address = $addressManager->createAddress();
//process insert/update
$this->get('oro_address.form.handler.address')->process($entity)
//accessing address form service
$this->get('oro_address.form.address')
oro_api_get_addresstype GET /api/rest/{version}/addresstypes/{name}.{_format} oro_api_get_addresstypes GET /api/rest/{version}/addresstypes.{_format}
Address collection may be added to form with next three steps
- Add field with type oro_address_collection to form
$builder->add(
'addresses',
'oro_address_collection',
array(
'required' => false,
'type' => 'oro_address'
)
);
- Add AddressCollectionTypeSubscriber. AddressCollectionTypeSubscriber must be initialized with address collection field name and address class name.
$builder->addEventSubscriber(new AddressCollectionTypeSubscriber('addresses', $this->addressClass));
- In template add OroAddressBundle:Include:fields.html.twig to support address form field typed
{% form_theme form with ['OroAddressBundle:Include:fields.html.twig']}