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

Fix e-notices on Address settings page, convert YesNo field #13004

Merged
merged 1 commit into from
Oct 30, 2018

Conversation

eileenmcnaughton
Copy link
Contributor

Overview

This fixes enotices

Before

screenshot 2018-10-25 09 38 22

After

screenshot 2018-10-25 10 04 18

Technical Details

We are converging the logic for handling settings on settings form into the SettingTrait - which is used by both Settings forms & Preferences. The difference between settings forms & preferences is arbitrary & historical & we are working to eliminate it. The final trait will be usable by extensions too. In fixing this e-notice I am also converting one of the fields over

@mattwire in doing this I wanted to look at your proposed changes here

https://github.com/civicrm/civicrm-core/pull/12932/files#diff-cd9367d6c33a74944159c2f7623db4a7R189 where you suggest changing html_type from 'radio' to 'YesNo' - my take on this is that the Quickform type is a quickform specific thing (like YesNo) but the html_type is a generic html type of element - I note this is NOT clearly documented & the docs treat html_type as a sub element of QF type. I suggest we discuss here & agree & then add a list of valid options here https://docs.civicrm.org/dev/en/latest/framework/setting/

Also I note that with the SettingTrait currently gives preference to quick_form_type & then handles html_type

  /**
   * Get the quickform type for the given html type.
   *
   * @param array $spec
   *
   * @return string
   */
  protected function getQuickFormType($spec) {
    if (isset($spec['quick_form_type'])) {
      return $spec['quick_form_type'];
    }
    $mapping = [
      'checkboxes' => 'CheckBoxes',
      'checkbox' => 'CheckBox',
      'radio' => 'Radio',
      'select' => 'Select',
      'textarea' => 'Element',
    ];
    return $mapping[$spec['html_type']];
  }

Comments

I don't think the discussion needs to block merge here - I think this is mergeable & discussion can continue

@civibot
Copy link

civibot bot commented Oct 24, 2018

(Standard links)

@mattwire
Copy link
Contributor

@eileenmcnaughton Needs rebase (conflict)

@@ -171,9 +171,13 @@ protected function addFieldsDefinedInSettingsMetadata() {
elseif ($add == 'addMonthDay') {
$this->add('date', $setting, ts($props['title']), CRM_Core_SelectValues::date(NULL, 'M d'));
}
elseif ($add === 'addYesNo' && ($props['type'] === 'Boolean')) {
$this->addRadio($setting, ts($props['title']), array(0 => 'No', 1 => 'Yes'), NULL, '  ');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most YesNo fields are displayed with Yes as the first element (see Settings -> Search Preferences and custom fields of type YesNo).
Can we flip this array so Yes is shown first on the UI?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@seamuslee001
Copy link
Contributor

@eileenmcnaughton needs rebase again now

This fixes enotices & also does our first preferences conversion of a YesNo / Radio field
@eileenmcnaughton
Copy link
Contributor Author

@mattwire @seamuslee001 this is now updated - note I had to change the url rule to not fail an empty value - I think that is sensible because the rule is checking value validity but the responsibility for checking presentness is elsewhere

@mattwire
Copy link
Contributor

I've tested this locally and I am happy that it is working. There is an issue with redirecting away from the page when validation fails on the URL but this was present before the changes. Merge on pass

@eileenmcnaughton eileenmcnaughton merged commit a9ab14a into civicrm:master Oct 30, 2018
@eileenmcnaughton eileenmcnaughton deleted the setting_address branch October 30, 2018 23:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants