What are the Slack Archives?
Itโs a history of our time together in the Slack Community! Thereโs a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.
Because this space is not active, you wonโt be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..
Hi everyone! I'm trying to implement multiple payment options. I now have AfterPay and Klarna. When
Hi everyone! I'm trying to implement multiple payment options. I now have AfterPay and Klarna. When i'm in checkout process on payment step i have
<
ul> element with list items in it. (Picture 1). When i select on let's say afterPay and press button to go to "Summary" step. Both of Sub Forms get validated even though i haven't selected one al all. Did anyone encounter problem like this ? How can i disable validation of certain subform if it has not been selected.
Comments
-
Did you end up with a solution?
0 -
No i did not.
0 -
I got one for you.
You have to add a callback constraint for the field you want to validate and check if the payment selection is the same as the subform name.field example:
/** * @param \Symfony\Component\Form\FormBuilderInterface $builder * @param array $options * * @return $this */ private function addPhoneField(FormBuilderInterface $builder, array $options) { $builder->add(static::FIELD_PHONE, TelType::class, [ 'label' => 'amazon.pay.phone.required', 'required' => true, 'trim' => true, 'data' => $options[SubFormInterface::OPTIONS_FIELD_NAME][static::FIELD_PHONE] ?? null, 'constraints' => [ new Callback([ 'callback' => function ($phone, ExecutionContextInterface $context) { /** @var Form $rootForm */ $rootForm = $context->getRoot(); if ($rootForm->get('paymentSelection')->getData() !== $this->getName()) { return; } if ($phone === null || $phone === '') { $context->buildViolation(static::VALIDATION_NOT_BLANK_MESSAGE)->addViolation(); } }, ]), ] ]); return $this; }
0 -
thanks. i'll try it out.
0
Categories
- All Categories
- 42 Getting Started & Guidelines
- 7 Getting Started in the Community
- 8 Additional Resources
- 7 Community Ideas and Feedback
- 76 Spryker News
- 929 Developer Corner
- 787 Spryker Development
- 89 Spryker Dev Environment
- 362 Spryker Releases
- 3 Oryx frontend framework
- 35 Propel ORM
- 68 Community Projects
- 3 Community Ideation Board
- 30 Hackathon
- 3 PHP Bridge
- 6 Gacela Project
- 26 Job Opportunities
- 3.2K ๐ Slack Archives
- 116 Academy
- 5 Business Users
- 370 Docker
- 551 Slack General
- 2K Help
- 75 Knowledge Sharing
- 6 Random Stuff
- 4 Code Testing
- 32 Product & Business Questions
- 70 Spryker Safari Questions
- 50 Random