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 Exam AD0-E716 Topic 12 Question 52 Discussion

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

An Adobe Commerce developer is tasked to add a file field to a custom form in the administration panel, the field must accept only .PDF files with size less or equal than 2 MB. So far the developer has added the following code within the form component xml file, inside the fieldset node:

How would the developer implement the validations?

A)

Add the Validations Within the HyVendor\MyModule\Controller\Adminhtml\CustomEntity\UploadPdf Controller

B)

Add a virtual type forMyvendor\MyModuie\Modei\customPdfupioader specifying the aiiowedExtensions and the maxFiiesize for the constructor, within the module's di.xmi:

C)

Add the following code inside the node:

Show Suggested Answer Hide Answer
Suggested Answer: B

The developer can add a virtual type for MyvendorMyModuieModeicustomPdfupioader specifying the aiiowedExtensions and the maxFiiesize for the constructor, within the module's di.xmi. This way, the developer can reuse the existing file uploader class and customize it for the specific field without modifying the core code. Verified Reference: [Magento 2.4 DevDocs] [Magento Stack Exchange]


Contribute your Thoughts:

William
3 hours ago
I'm leaning towards Option B as well. Putting the validation in the DI configuration keeps the form component clean and reusable. Plus, it allows you to easily change the validation rules in one place if needed.
upvoted 0 times
...
Jerry
6 days ago
Option B seems like the way to go. Encapsulating the validation logic in a custom uploader class and configuring it in the DI makes the most sense to me. That way the form component can just use the uploader without having to worry about the validation details.
upvoted 0 times
...
Mattie
11 days ago
I'm a bit confused by the different options. Option A seems to put the validation logic in the controller, which doesn't seem quite right for a form field. Option C looks interesting, but I'm not sure if that's the best place to handle the validation.
upvoted 0 times
...
Luis
17 days ago
I think Option B looks the most straightforward. Adding a virtual type to specify the allowed extensions and max file size seems like a clean way to handle the validation.
upvoted 0 times
...

Save Cancel