Cyber Monday 2024! 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 4 Question 31 Discussion

Actual exam question for Adobe's AD0-E716 exam
Question #: 31
Topic #: 4
[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:

Mary
2 months ago
Option C? Really? What is this, amateur hour? You might as well just hardcode the file size limit in the frontend.
upvoted 0 times
Jerry
29 days ago
Yeah, Option C does seem a bit amateurish. Hardcoding limits is never a good idea.
upvoted 0 times
...
Helene
2 months ago
I agree, Option B looks like a more structured approach.
upvoted 0 times
...
Tomoko
2 months ago
Option A seems like the correct way to go.
upvoted 0 times
...
...
Cheryl
2 months ago
Hmm, I don't know... Option C seems the most elegant to me. Putting the validation settings right in the XML feels like the most Magento-esque approach.
upvoted 0 times
...
Ellen
2 months ago
But Option A could get messy if you have multiple file uploads in your form. Option B keeps the validation logic isolated and reusable.
upvoted 0 times
...
Wendell
2 months ago
I'm not sure, but Option C also looks like a valid approach to me.
upvoted 0 times
...
Darell
2 months ago
I'm not sure I agree. Option A seems more straightforward - why not just add the validation in the controller? That way you can have complete control over the logic.
upvoted 0 times
Johnetta
1 months ago
User2: True, but Option B provides a more structured way to handle the file validations.
upvoted 0 times
...
Leana
1 months ago
Option C might be a good choice too. Adding the code inside the node could provide a clean solution.
upvoted 0 times
...
Remona
1 months ago
I see your point, but Option B also looks promising. Setting the allowed extensions and max file size in the constructor could be efficient.
upvoted 0 times
...
Gregg
1 months ago
I agree with User1, keeping it simple with Option A in the controller is a good approach.
upvoted 0 times
...
Merri
1 months ago
I think Option A is the way to go. Adding the validation in the controller gives us more control.
upvoted 0 times
...
Lenna
2 months ago
Option B could work too. Setting the allowed extensions and max file size in the constructor.
upvoted 0 times
...
Brice
2 months ago
I think Option A is the way to go. Adding the validation in the controller gives more control.
upvoted 0 times
...
...
Pedro
3 months ago
I agree with Cristy, Option B seems like the best choice for implementing the validations.
upvoted 0 times
...
Cristy
3 months ago
I think the developer should go with Option B.
upvoted 0 times
...
Miles
3 months ago
Option B looks good to me. Using a virtual type to specify the allowed extensions and max file size sounds like the cleanest way to handle this validation.
upvoted 0 times
Fannie
2 months ago
I agree, Option B seems like the most organized approach for adding file field validations.
upvoted 0 times
...
Destiny
3 months ago
Option B looks good to me. Using a virtual type to specify the allowed extensions and max file size sounds like the cleanest way to handle this validation.
upvoted 0 times
...
...

Save Cancel