src/Bidcoz/Bundle/FrontendBundle/Form/Type/Donation/CashType.php line 16

Open in your IDE?
  1. <?php
  2. namespace Bidcoz\Bundle\FrontendBundle\Form\Type\Donation;
  3. use RS\DiExtraBundle\Annotation as DI;
  4. use Symfony\Component\Form\AbstractType;
  5. use Symfony\Component\Form\Extension\Core\Type\HiddenType;
  6. use Symfony\Component\Form\Extension\Core\Type\MoneyType;
  7. use Symfony\Component\Form\FormBuilderInterface;
  8. use Symfony\Component\Validator\Constraints\NotBlank;
  9. use Symfony\Component\Validator\Constraints\Range;
  10. /**
  11.  * @DI\FormType
  12.  */
  13. class CashType extends AbstractType
  14. {
  15.     public function buildForm(FormBuilderInterface $builder, array $options)
  16.     {
  17.         $builder
  18.             ->add('amount'MoneyType::class, [
  19.                 'currency'    => 'USD',
  20.                 'attr'        => [
  21.                     'placeholder' => 'Enter a custom amount',
  22.                 ],
  23.                 'constraints' => [
  24.                     new NotBlank(),
  25.                     new Range([
  26.                         'min' => 0,
  27.                     ]),
  28.                 ],
  29.             ])
  30.             // CAU-380: one-time (default) or monthly. 'monthly' turns the gift
  31.             // into a recurring Stripe subscription in the controller, reusing the
  32.             // Fundraising/Membership subscription path. stripeToken is filled by
  33.             // Stripe Checkout only on the monthly path.
  34.             ->add('frequency'HiddenType::class, [
  35.                 'data'     => 'one-time',
  36.                 'required' => false,
  37.             ])
  38.             ->add('stripeToken'HiddenType::class, [
  39.                 'required' => false,
  40.             ])
  41.         ;
  42.     }
  43.     public function getBlockPrefix()
  44.     {
  45.         return 'donate_cash';
  46.     }
  47. }