Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace Louis\DataImportBundle\Form\Type\Halcom;
- use Louis\CoreBundle\Entity\Invoice\Payment;
- use Louis\CoreBundle\Entity\Transaction\TransactionFee;
- use Louis\DataImportBundle\Form\Type\PaymentType;
- use Louis\DataImportBundle\Form\Type\TransactionFeeType;
- use Symfony\Component\Form\AbstractType;
- use Symfony\Component\Form\Extension\Core\Type\CollectionType;
- use Symfony\Component\Form\FormBuilderInterface;
- use Symfony\Component\Form\FormInterface;
- use Symfony\Component\OptionsResolver\OptionsResolver;
- use Symfony\Component\Validator\Constraints\Valid;
- class ProcessDomesticTransactionsStatementsType extends AbstractType
- {
- public function buildForm(FormBuilderInterface $builder, array $options)
- {
- parent::buildForm($builder, $options);
- $builder
- ->add('payments', CollectionType::class, array(
- 'entry_type' => PaymentType::class,
- 'entry_options' => [
- 'data_class' => Payment::class,
- 'constraints' => new Valid(),
- 'validation_groups' => function(FormInterface $form) {
- if (false === $form->get('import')->getData()) {
- return [];
- }
- return ['Default'];
- }
- ],
- 'allow_add' => false,
- 'allow_delete' => false
- ))
- ->add('fees', CollectionType::class, array(
- 'entry_type' => TransactionFeeType::class,
- 'entry_options' => [
- 'data_class' => TransactionFee::class,
- 'constraints' => new Valid(),
- 'validation_groups' => function(FormInterface $form) {
- if (false === $form->get('import')->getData()) {
- return [];
- }
- return ['Default'];
- }
- ],
- 'allow_add' => false,
- 'allow_delete' => false
- ))
- ;
- }
- public function configureOptions(OptionsResolver $resolver)
- {
- $resolver
- ->setDefault('novalidate', true)
- // This below is optional, it is by default
- ->setDefault('validation_groups', ['Default'])
- ;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment