From c600b8ac216727f99a9ad11dd1fdab8c01f61f38 Mon Sep 17 00:00:00 2001 From: monishdeb Date: Mon, 7 Dec 2015 19:52:26 +0530 Subject: [PATCH] CRM-17308 fix - Location type 'select' (for all entities) AND Phone type should be required https://issues.civicrm.org/jira/browse/CRM-17308 --- CRM/Contact/Form/Contact.php | 12 +++++------- CRM/Contact/Form/Edit/Address.php | 5 ++--- CRM/Core/Form.php | 3 ++- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/CRM/Contact/Form/Contact.php b/CRM/Contact/Form/Contact.php index 4d30d0c019..1d2dba8fb6 100644 --- a/CRM/Contact/Form/Contact.php +++ b/CRM/Contact/Form/Contact.php @@ -510,13 +510,11 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { for ($instance = 1; $instance <= $this->get($blockName . '_Block_Count'); $instance++) { // make we require one primary block, CRM-5505 - if ($updateMode) { - if (!$hasPrimary) { - $hasPrimary = CRM_Utils_Array::value( - 'is_primary', - CRM_Utils_Array::value($instance, $defaults[$name]) - ); - } + if ($updateMode && !$hasPrimary) { + $hasPrimary = CRM_Utils_Array::value( + 'is_primary', + CRM_Utils_Array::value($instance, $defaults[$name]) + ); continue; } diff --git a/CRM/Contact/Form/Edit/Address.php b/CRM/Contact/Form/Edit/Address.php index efb187b519..d46c6a837f 100644 --- a/CRM/Contact/Form/Edit/Address.php +++ b/CRM/Contact/Form/Edit/Address.php @@ -68,7 +68,6 @@ class CRM_Contact_Form_Edit_Address { //make location type required for inline edit $form->addField("address[$blockId][location_type_id]", array('entity' => 'address', 'class' => 'eight') + $js, $inlineEdit); - if (!$inlineEdit) { $js = array('id' => 'Address_' . $blockId . '_IsPrimary', 'onClick' => 'singleSelect( this.id );'); } @@ -86,8 +85,8 @@ class CRM_Contact_Form_Edit_Address { $form->addField( "address[$blockId][is_billing]", array( 'entity' => 'address', - 'label' => ts('Primary location for this contact'), - 'text' => ts('Primary location for this contact')) + $js); + 'label' => ts('Billing location for this contact'), + 'text' => ts('Billing location for this contact')) + $js); // hidden element to store master address id $form->addField("address[$blockId][master_id]", array('entity' => 'address', 'type' => 'hidden')); diff --git a/CRM/Core/Form.php b/CRM/Core/Form.php index da258205e6..8b128ae24a 100644 --- a/CRM/Core/Form.php +++ b/CRM/Core/Form.php @@ -1495,7 +1495,8 @@ class CRM_Core_Form extends HTML_QuickForm_Page { return $this->addRadio($name, $label, $options, $props, $separator, $required); case 'Select': - if (empty($props['multiple'])) { + unset($props['size']); + if (empty($props['multiple']) && !empty($props['placeholder'])) { $options = array('' => $props['placeholder']) + $options; } if (!empty($props['data-api-field']) && (in_array($props['data-api-field'], array('state_province_id', 'county_id')))) { -- 2.25.1