소스 검색

Merge branch 'hotfix/hotfix_529'

master
Guillaume Bourgeois 2 년 전
부모
커밋
3ec7d3cf4d
1개의 변경된 파일22개의 추가작업 그리고 2개의 파일을 삭제
  1. +22
    -2
      Form/Reduction/EditGiftVoucherType.php

+ 22
- 2
Form/Reduction/EditGiftVoucherType.php 파일 보기

@@ -7,6 +7,8 @@ use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;

class EditGiftVoucherType extends AbstractType
@@ -18,7 +20,6 @@ class EditGiftVoucherType extends AbstractType
'label' => 'Date d\'activation de votre bon cadeau :',
'widget'=> 'single_text',
'help'=> 'Date à partir de laquelle la personne pourra utiliser ce bon cadeau.'
//'format'=> 'dd/MM/yyyy'
])
->add('title', TextType::class, [
'label' => 'Message personnalisé affiché dans le bon cadeau :',
@@ -32,12 +33,31 @@ class EditGiftVoucherType extends AbstractType
'label' => 'Offert par :',
'help'=> 'Sera affiché dans le bon cadeau'
]);

$builder->addEventListener(FormEvents::POST_SET_DATA, function (FormEvent $event) use ($options) {
if (isset($options['reduction_gift']) && $options['reduction_gift']) {
$reductionGift = $options['reduction_gift'];
$form = $event->getForm();
if (!$form->isSubmitted()) {
if ($reductionGift->getActivationDate()) {
$form->get('activationDate')->setData($reductionGift->getActivationDate());
}
if ($reductionGift->getUsers()->count()) {
$form->get('email')->setData($reductionGift->getUsers()[0]->getEmail());
}
if ($reductionGift->getOwnerName()) {
$form->get('ownerName')->setData($reductionGift->getOwnerName());
}
$form->get('title')->setData($reductionGift->getTitle());
}
}
});
}

public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
// Configure your form options here
'reduction_gift' => null
]);
}
}

Loading…
취소
저장