40564: Added support for 'disabled' state for individual select options#40565
Conversation
|
Hi @rybkinevg. Thank you for your contribution!
Allowed build names are:
You can find more information about the builds here For more details, review the Code Contributions documentation. |
|
@magento run all tests |
|
@magento run Static Tests |
|
@magento run all tests |
There was a problem hiding this comment.
Pull request overview
Adds framework-level support for disabling individual <option> entries in Magento\Framework\Data\Form\Element\Select, enabling source models to mark specific options as non-selectable (e.g., via ['disabled' => true]).
Changes:
- Render
disabled="disabled"on<option>when the option array contains a truthydisabledflag. - Add unit coverage validating disabled option rendering for both plain options and options within an
<optgroup>.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| lib/internal/Magento/Framework/Data/Form/Element/Select.php | Adds disabled="disabled" attribute rendering for per-option disabled state. |
| lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/SelectTest.php | New unit tests covering disabled option rendering (including optgroups) across various disabled values. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/SelectTest.php
Outdated
Show resolved
Hide resolved
|
@magento run all tests |
ihor-sviziev
left a comment
There was a problem hiding this comment.
Functional test failures look as a false positives, so approving
|
@ihor-sviziev, since PR is approved, what are the next steps? is there anything else required of me? |
Description (*)
Added support for the
disabledproperty on individual<option>elements within select form fields.If the
disabledkey is set totruein the option array it renders thedisabled="disabled"attribute accordingly.Fixed Issues (if relevant)
Manual testing scenarios (*)
№1 Modify the builtin source model:
Open the file:
app/code/Magento/Config/Model/Config/Source/Yesno.phpand modify thetoOptionArray()method to adddisabledproperty to the "No" option:№2 Clear Cache
№3 Navigate to admin configuration area
Go to
Stores->Configuration->General->Web, expand theUrl Optionssection№4 Verify the "Add Store Code to Urls" Field
Click on the dropdown to expand the options, the "No" option is disabled
Questions or comments
Current implementation treats all truthy values of the
disabledproperty as the disabled state:I am not sure, is this correct, or should we treat only explicitly true values as disabled state? For example:
Contribution checklist (*)