3. Forms


We’re sorry but this documentation section is outdated. Please have that in mind when trying to use it. You can help us making documentation up to date via Sylius Github. Thank you!

The bundle ships with a set of useful form types for all models. You can use the defaults or override them with your own types.

3.1. Address form

The address form type is named sylius_address and you can create it whenever you need, using the form factory.


// src/Acme/ShopBundle/Controller/AddressController.php

namespace Acme\ShopBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;

class DemoController extends Controller
    public function fooAction(Request $request)
        $form = $this->get('form.factory')->create('sylius_address');

You can also embed it into another form.


// src/Acme/ShopBundle/Form/Type/OrderType.php

namespace Acme\ShopBundle\Form\Type;

use Sylius\Bundle\OrderBundle\Form\Type\OrderType as BaseOrderType;
use Symfony\Component\Form\FormBuilderInterface;

class OrderType extends BaseOrderType
    public function buildForm(FormBuilderInterface $builder, array $options)
        parent::buildForm($builder, $options);

            ->add('billingAddress', 'sylius_address')
            ->add('shippingAddress', 'sylius_address')