Simplify Domain edit form to not call complete LocationBlock build
authorEileen McNaughton <emcnaughton@wikimedia.org>
Sun, 21 Aug 2022 22:53:03 +0000 (10:53 +1200)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Sun, 21 Aug 2022 22:56:39 +0000 (10:56 +1200)
CRM/Contact/Form/Domain.php
templates/CRM/Contact/Form/Domain.tpl

index 75065706800da0d51a54a8bd548ec01c1b8448ce..fd938776f060ea1f6b1aff0f71f556d1c80c8afd 100644 (file)
@@ -48,25 +48,17 @@ class CRM_Contact_Form_Domain extends CRM_Core_Form {
    */
   protected $_locationDefaults = [];
 
-  /**
-   * How many locationBlocks should we display?
-   *
-   * @var int
-   * @const
-   */
-  const LOCATION_BLOCKS = 1;
-
   /**
    * Explicitly declare the entity api name.
    */
-  public function getDefaultEntity() {
+  public function getDefaultEntity(): string {
     return 'Domain';
   }
 
   /**
    * Explicitly declare the form context.
    */
-  public function getDefaultContext() {
+  public function getDefaultContext(): string {
     return 'create';
   }
 
@@ -121,13 +113,17 @@ class CRM_Contact_Form_Domain extends CRM_Core_Form {
 
   /**
    * Build the form object.
+   *
+   * @throws \CiviCRM_API3_Exception
    */
-  public function buildQuickForm() {
+  public function buildQuickForm(): void {
     $this->addField('name', ['label' => ts('Organization Name')], TRUE);
     $this->addField('description', ['label' => ts('Description'), 'size' => 30]);
 
     //build location blocks.
-    CRM_Contact_Form_Location::buildQuickForm($this);
+    CRM_Contact_Form_Edit_Address::buildQuickForm($this, 1);
+    CRM_Contact_Form_Edit_Email::buildQuickForm($this, 1);
+    CRM_Contact_Form_Edit_Phone::buildQuickForm($this, 1);
 
     $this->addButtons([
       [
index ed1044c78f2f04e2a77182691201d4ed9864d7b4..5a1bc69c726deaa27b4e84d60d6627eda9b95fef 100644 (file)
 
     <h3>{ts}Default Organization Address{/ts}</h3>
         <div class="description">{ts 1=&#123;domain.address&#125;}CiviMail mailings must include the sending organization's address. This is done by putting the %1 token in either the body or footer of the mailing. This token may also be used in regular 'Email - send now' messages and in other Message Templates. The token is replaced by the address entered below when the message is sent.{/ts}</div>
-        {include file="CRM/Contact/Form/Edit/Address.tpl" masterAddress='' parseStreetAddress=''}
+        {include file="CRM/Contact/Form/Edit/Address.tpl" blockId=1 masterAddress='' parseStreetAddress=''}
     <h3>{ts}Organization Contact Information{/ts}</h3>
         <div class="description">{ts}You can also include general email and/or phone contact information in mailings.{/ts} {help id="additional-contact"}</div>
         <table class="form-layout-compressed">
             {* Display the email block *}
-            {include file="CRM/Contact/Form/Edit/Email.tpl"}
+            {include file="CRM/Contact/Form/Edit/Email.tpl" blockId=1}
 
             {* Display the phone block *}
-            {include file="CRM/Contact/Form/Edit/Phone.tpl"}
+            {include file="CRM/Contact/Form/Edit/Phone.tpl" blockId=1}
         </table>
 
     <div class="spacer"></div>