Symfony\Component\Form\FormFactory::create PHP Метод

create() публичный Метод

public create ( $type = 'form', $data = null, array $options = [], Symfony\Component\Form\FormBuilderInterface $parent = null )
$options array
$parent Symfony\Component\Form\FormBuilderInterface
    public function create($type = 'form', $data = null, array $options = array(), FormBuilderInterface $parent = null)
    {
        return $this->createBuilder($type, $data, $options, $parent)->getForm();
    }

Usage Example

Пример #1
0
 /**
  * {@inheritdoc}
  */
 public function resolveItemToAdd(Request $request)
 {
     /*
      * We're getting here product set id via query but you can easily override route
      * pattern and use attributes, which are available through request object.
      */
     if ($id = $request->query->get('id')) {
         if ($product_set = $this->productSetManager->findSet($id)) {
             /*
              * To have it flexible, we allow adding single item by GET request
              * and also user can provide desired quantity by form via POST request.
              */
             $item = $this->itemManager->createItem();
             $item->setProductSet($product_set);
             if ('POST' === $request->getMethod()) {
                 $form = $this->formFactory->create('chewbacca_cart_item');
                 $form->setData($item);
                 $form->bindRequest($request);
                 if (!$form->isValid()) {
                     return false;
                 }
             }
             return $item;
         }
     }
 }
All Usage Examples Of Symfony\Component\Form\FormFactory::create