Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Adobe AD0-E716 Exam - Topic 1 Question 63 Discussion

An Adobe Commerce Developer is tasked with creating a custom form which submits its data to a frontend controller They have decided to create an action and have implemented the \Magento\Framework\App\Action\HttpPostActioninterface class, but are not seeing the data being persisted in the database, and an error message is being shown on the frontend after submission.After debugging and ensuring that the data persistence logic is correct, what may be cause and solution to this?
C) Form key validation runs on all non-AJAX POST requests, the developer needs to add the for_key to their requests.
A) Magento does not allow POST requests to a frontend controller, therefore, the submission functionality will need to be rewritten as an API endpoint.
B) The developer forgot to implement a validatePostDataQ method in their action. They should implement this method: all non-validated POST data gets stripped out of the request and an error is thrown.

Adobe AD0-E716 Exam - Topic 1 Question 63 Discussion

Actual exam question for Adobe's AD0-E716 exam
Question #: 63
Topic #: 1
[All AD0-E716 Questions]

An Adobe Commerce Developer is tasked with creating a custom form which submits its data to a frontend controller They have decided to create an action and have implemented the \Magento\Framework\App\Action\HttpPostActioninterface class, but are not seeing the data being persisted in the database, and an error message is being shown on the frontend after submission.

After debugging and ensuring that the data persistence logic is correct, what may be cause and solution to this?

Show Suggested Answer Hide Answer
Suggested Answer: C

According to the Magento Stack Exchange answer, form key validation is a security feature that prevents CSRF attacks by checking if the form key in the request matches the one generated by Magento. If the developer does not include the form_key in their custom form, the validation will fail and an error will be shown. Therefore, the developer needs to add the form_key to their requests by using <?= $block->getBlockHtml ('formkey') ?> in their template file. Verified Reference: https://magento.stackexchange.com/questions/95171/magento-2-form-validation


Contribute your Thoughts:

0/2000 characters
Elvera
2 hours ago
True, but what about form key validation? C could be the reason too.
upvoted 0 times
...
Margart
5 days ago
I feel like B is the issue. Missing validatePostDataQ could cause problems.
upvoted 0 times
...
Elvera
10 days ago
This question is tricky. I think option A makes sense.
upvoted 0 times
...
Delisa
16 days ago
Yeah, definitely. Always check the form key first!
upvoted 0 times
...
Denny
21 days ago
I’d go with C then. It’s a common mistake.
upvoted 0 times
...
Delisa
26 days ago
Right! If the form key is missing, it won't work.
upvoted 0 times
...
Denny
1 month ago
True, but what about form key validation? C could be the reason too.
upvoted 0 times
...
Delisa
1 month ago
I feel like B is the issue. Missing validatePostDataQ could cause problems.
upvoted 0 times
...
Denny
1 month ago
This question is tricky. I think option A makes sense.
upvoted 0 times
...
Luis
2 months ago
Yup, C is the way to go, had the same issue before!
upvoted 0 times
...
Shelia
2 months ago
Wait, are we sure about C? I thought form keys were optional.
upvoted 0 times
...
Tomas
2 months ago
B sounds right, forgot to validate the data probably.
upvoted 0 times
...
Lanie
2 months ago
A is definitely not true, POST requests can work with frontend controllers.
upvoted 0 times
...
Hillary
2 months ago
I think option C makes sense, form key validation is crucial.
upvoted 0 times
...
Jacqueline
2 months ago
I feel like I’ve seen something about form keys being required for non-AJAX requests. Maybe that’s what’s going wrong here?
upvoted 0 times
...
Joesph
3 months ago
I practiced a similar question before, and I think Magento does allow POST requests, so option A seems unlikely.
upvoted 0 times
...
Kris
3 months ago
I’m not entirely sure, but I think if the validatePostData method is missing, it could definitely cause issues. That sounds like option B.
upvoted 0 times
...
Mose
3 months ago
I remember something about form key validation being crucial for POST requests in Magento. Could it be option C?
upvoted 0 times
...

Save Cancel