src/Flowcode/ShopBundle/Form/StrategyType.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('product', EntityType::class, array(
                'class' => Product::class,
                'choice_label' => function ($product) {
                    return $product->getName();
                },
                'multiple' => false,
            ))
            ->add('categories', 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' => true,
            ))
            ->add('factor', PercentType::class, array("label" => "Factor descuento"));
    }
public function buildForm ( FormBuilderInterface $ builder , array $ options ) { $ builder -> add ( 'name' ) -> add ( 'product' , EntityType :: class , array ( 'class' => Product :: class , 'choice_label' => function ( $ product ) { return $ product -> getName ( ) ; } , 'multiple' => false , ) ) -> add ( 'categories' , 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' => true , ) ) -> add ( 'factor' , PercentType :: class , array ( " label " => " Factor descuento " ) ) ; }
@param FormBuilderInterface $builder
 @param array $options
@param FormBuilderInterface $builder @param array $options