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

Wrap "not you" message in crmRegion #18236

Merged
merged 1 commit into from
Aug 24, 2020
Merged

Conversation

mattwire
Copy link
Contributor

Overview

On both contribution pages and registration pages there is a "Not you, do you want to register for someone else" message. I've had requests from various clients to hide this and you can generally do it with javascript. But it's not ideal, it often "flashes" on screen before disappearing, if there is a javascript error it doesn't disappear, if you don''t load the javascript (eg. when a contribution is inserted via shortcode on wordpress).

This wraps the message in a crmRegion so that it can be removed/replaced via the buildForm hook before it reaches the browser. Example:

/**
 * Intercept form functions
 * @param string $formName
 * @param \CRM_Core_Form $form
 */
function bafamembers_civicrm_buildForm($formName, &$form) {
  switch ($formName) {
    case 'CRM_Contribute_Form_Contribution_Main':
      CRM_Core_Region::instance('contribution-main-not-you-block')
        ->update('default', ['disabled' => TRUE]);
      break;

    case 'CRM_Event_Form_Registration_Register':
      CRM_Core_Region::instance('event-register-not-you-block')
        ->update('default', ['disabled' => TRUE]);
      break;
  }
}

Before

Described above.

After

No change. By implementing code you can modify/remove the message div from the form.

Technical Details

Comments

@civibot
Copy link

civibot bot commented Aug 22, 2020

(Standard links)

@civibot civibot bot added the master label Aug 22, 2020
@mattwire
Copy link
Contributor Author

I'll add documentation here once merged: https://docs.civicrm.org/dev/en/latest/framework/region/

@colemanw
Copy link
Member

Is there any reason to give them different names?
I perceive them as the same region on different forms, so I would give both regions the same name.

@mattwire
Copy link
Contributor Author

@colemanw Yes, last time I added a region to both I was asked to name them differently. My first thought was to name them the same and I'd be happy to do so - can you confirm which you'd prefer and I'll update?

@colemanw
Copy link
Member

Hmm, which region was that?

@mattwire
Copy link
Contributor Author

@colemanw
Copy link
Member

Ok, I'm not sure why regions would have to have different names if they are the same region on different forms, since you can target a particular form in your hook if you wish.
@eileenmcnaughton ?

@eileenmcnaughton
Copy link
Contributor

@colemanw I believe it was consistency with the others that already existed at that time

@demeritcowboy
Copy link
Contributor

For what it's worth the doclink referenced has a naming conventions section that says make them match the file path. But reasoning is not stated. https://docs.civicrm.org/dev/en/latest/framework/region/#naming-conventions

@colemanw
Copy link
Member

Ok whatever.

@colemanw colemanw merged commit 0374b8b into civicrm:master Aug 24, 2020
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.

4 participants