Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Settings Fix setting readonly attribute #16451

Merged
merged 1 commit into from Feb 14, 2020

Conversation

mattwire
Copy link
Contributor

@mattwire mattwire commented Feb 1, 2020

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:

$(document).ready(function() {
  CRM.$('input[readonly]').attr('disabled', true);
});

(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;

@civibot
Copy link

civibot bot commented Feb 1, 2020

(Standard links)

@civibot civibot bot added the master label Feb 1, 2020
@seamuslee001
Copy link
Contributor

Jenkins re test this please

@colemanw
Copy link
Member

colemanw commented Feb 3, 2020

re retest this please

@yashodha
Copy link
Contributor

yashodha commented Feb 3, 2020

@mattwire Does this take care of Authentication? for SMTP Configuration as well?

@mattwire
Copy link
Contributor Author

mattwire commented Feb 3, 2020

@yashodha I tried doing $civicrm_setting['mailing']['mailing_backend']['outBound_option'] = 2; but it didn't seem to make it through to Civi. So there might be another issue or I might not be specifying it properly in the civicrm.settings.php. But if the setting is picked up by Civi then it should get flagged as readonly on the form.

@mattwire
Copy link
Contributor Author

@yashodha So this doesn't work with settings that are serialised before being stored in the DB but it didn't before. It does fix radio elements that are saved directly. Is this ok to merge? Then we could look at improving the other cases.

@eileenmcnaughton
Copy link
Contributor

I think this makes sense to merge - it's form level & is logical. The only issue seems to be that non-standard settings don't benefit from it - a bridge for another day

@eileenmcnaughton eileenmcnaughton merged commit 2ef461d into civicrm:master Feb 14, 2020
@mattwire mattwire deleted the settingreadonly branch March 15, 2020 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
5 participants