3. Forms¶

Danger

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 forms.

3.1. Product form¶

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

<?php

// src/Acme/ShopBundle/Controller/ProductController.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_product');
    }
}

The default product form consists of following fields.

Field Type
name text
description textarea
metaDescription text
metaKeywords text

You can render each of these using the usual Symfony way {{ form_row(form.description) }}.