Settings Fix setting readonly attribute #16451
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
When the value of a mandatory setting (ie. defined via civicrm.settings.php) is 0 - eg. for
empoweredBy
and other radio elements the check incorrectly sets them as not readonly.Before
Attribute readonly not set on input elements that have a mandatory value of 0.
After
Attribute readonly set correctly.
Technical Details
The
if
needs to explicitly check for NULL. Note that for radio input elements setting attribute readonly is not enough for them to actually be readonly... But this adds the attribute indicating that they should be readonly and you can then do something like:(I'm currently doing this in https://lab.civicrm.org/extensions/haystacktheme).
Comments
You'll need to use the browser console to inspect the element and see that it has
readonly="1"
set after this PR if you've defined it in civicrm.settings.php. Eg.$civicrm_setting['core']['empoweredBy'] = 0;