Example #1
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     parent::buildForm($builder, $options);
     $builder->add('promotionCoupons', 'collection', array('type' => 'sylius_promotion_coupon_to_code', 'allow_add' => true, 'allow_delete' => true, 'by_reference' => false, 'label' => 'sylius.form.cart.coupon'))->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
         $data = $event->getData();
         if (!$data->getPromotionCoupons()->isEmpty()) {
             return;
         }
         $data->addPromotionCoupon($this->couponFactory->createNew());
     });
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     parent::buildForm($builder, $options);
     $builder->add('promotionCoupon', 'sylius_promotion_coupon_to_code', ['by_reference' => false, 'label' => 'sylius.form.cart.coupon'])->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
         $data = $event->getData();
         if (null !== $data->getPromotionCoupon()) {
             return;
         }
         if ($event->getForm()->has('promotionCoupon')) {
             $data->setPromotionCoupon($this->couponFactory->createNew());
         }
     });
 }
Example #3
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     parent::buildForm($builder, $options);
     $builder->add('promotionCoupon', 'sylius_promotion_coupon_to_code', ['by_reference' => false, 'label' => 'sylius.form.cart.coupon', 'required' => false]);
 }