src/Flowcode/ShopBundle/Form/ProductType.php
/**
     * @param FormBuilderInterface $builder
     * @param array $options
     */
@param FormBuilderInterface $builder
@param array $options
@param FormBuilderInterface $builder @param array $options
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('name')
            ->add('description')
            ->add('category', EntityType::class, array(
                'class' => Category::class,
                'choices' => $this->categoryService->findByRoot("product"),
                'choice_label' => function ($category, $key, $index) {
                    $prefix = "";
                    for ($i = 0; $i < $category->getLvl(); $i++) {
                        $prefix .= "-";
                    }
                    return strtolower($prefix . $category->getName());
                },
                'multiple' => false,
            ))
            ->add('price', 'text', array("label" => "Precio"))
            ->add('enabled')
            ->add('pack')
            ->add('warehouse')
            ->add('featured')
            ->add('manualStock')
            ->add('manualPackPricing')
            ->add('tags', 'collection', array("type" => new Tag(), "label" => "Etiquetas"))
            ->add('mediaGallery', null, array("label" => "Galería de medios"))
            ->add('content', 'ckeditor')
            ->add('brand')
            ->add('capacity')
            ->add('rawMaterials', 'collection', array(
                'type' => new ProductRawMaterialType($builder->getData()),
                'allow_add' => true,
                'by_reference' => false,
                'allow_delete' => true
            ))
            ->add('productItemFieldDatas', CollectionType::class, array(
                'entry_type' => ProductItemFieldDataType::class,
                'label' => false,
                'required' => false
            ));
    }
public function buildForm ( FormBuilderInterface $ builder , array $ options ) { $ builder -> add ( 'name' ) -> add ( 'description' ) -> add ( 'category' , EntityType :: class , array ( 'class' => Category :: class , 'choices' => $ this -> categoryService -> findByRoot ( " product " ) , 'choice_label' => function ( $ category , $ key , $ index ) { $ prefix = " " ; for ( $ i = 0 ; $ i < $ category -> getLvl ( ) ; $ i ++ ) { $ prefix .= " - " ; } return strtolower ( $ prefix . $ category -> getName ( ) ) ; } , 'multiple' => false , ) ) -> add ( 'price' , 'text' , array ( " label " => " Precio " ) ) -> add ( 'enabled' ) -> add ( 'pack' ) -> add ( 'warehouse' ) -> add ( 'featured' ) -> add ( 'manualStock' ) -> add ( 'manualPackPricing' ) -> add ( 'tags' , 'collection' , array ( " type " => new Tag ( ) , " label " => " Etiquetas " ) ) -> add ( 'mediaGallery' , null , array ( " label " => " Galería de medios" ) ) -> add ( 'content' , 'ckeditor' ) -> add ( 'brand' ) -> add ( 'capacity' ) -> add ( 'rawMaterials' , 'collection' , array ( 'type' => new ProductRawMaterialType ( $ builder -> getData ( ) ) , 'allow_add' => true , 'by_reference' => false , 'allow_delete' => true ) ) -> add ( 'productItemFieldDatas' , CollectionType :: class , array ( 'entry_type' => ProductItemFieldDataType :: class , 'label' => false , 'required' => false ) ) ; }
@param FormBuilderInterface $builder
 @param array $options
@param FormBuilderInterface $builder @param array $options