From eef9a6da59fc84e0d190153dc136c1eb3bcbc948 Mon Sep 17 00:00:00 2001 From: JKingsnorth Date: Wed, 20 May 2015 12:07:06 +0100 Subject: [PATCH] CRM-16531 Remove automatic http:// in website fields --- CRM/Contact/Form/Edit/Website.php | 9 +++------ CRM/Core/BAO/CustomField.php | 4 +--- CRM/Core/BAO/UFGroup.php | 12 ++---------- 3 files changed, 6 insertions(+), 19 deletions(-) diff --git a/CRM/Contact/Form/Edit/Website.php b/CRM/Contact/Form/Edit/Website.php index faf7c292c6..4336313c55 100644 --- a/CRM/Contact/Form/Edit/Website.php +++ b/CRM/Contact/Form/Edit/Website.php @@ -60,14 +60,11 @@ class CRM_Contact_Form_Edit_Website { //Website type select $form->addField("website[$blockId][website_type_id]", array('entity' => 'website', 'class' => 'eight')); + //Website box - $form->addField("website[$blockId][url]", array( - 'entity' => 'website', - 'onfocus' => "if (!this.value) { this.value='http://';} else return false", - 'onblur' => "if ( this.value == 'http://') { this.value='';} else return false", - )); + $form->addField("website[$blockId][url]", array('entity' => 'website')); + $form->addRule("website[$blockId][url]", ts('Enter a valid web address beginning with \'http://\' or \'https://\'.'), 'url'); - $form->addRule("website[$blockId][url]", ts('Enter a valid web location beginning with \'http://\' or \'https://\'. EXAMPLE: http://www.mysite.org/'), 'url'); } } diff --git a/CRM/Core/BAO/CustomField.php b/CRM/Core/BAO/CustomField.php index 080b17c9c9..21abca06f1 100644 --- a/CRM/Core/BAO/CustomField.php +++ b/CRM/Core/BAO/CustomField.php @@ -1063,10 +1063,8 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField { break; case 'Link': - $element->setAttribute('onfocus', "if (!this.value) {this.value='http://';}"); - $element->setAttribute('onblur', "if (this.value == 'http://') {this.value='';}"); $element->setAttribute('class', "url"); - $qf->addRule($elementName, ts('Enter a valid Website.'), 'wikiURL'); + $qf->addRule($elementName, ts('Enter a valid web address beginning with \'http://\' or \'https://\'.'), 'wikiURL'); break; } if ($field->is_view && !$search) { diff --git a/CRM/Core/BAO/UFGroup.php b/CRM/Core/BAO/UFGroup.php index 542e3e8442..c7937f8526 100644 --- a/CRM/Core/BAO/UFGroup.php +++ b/CRM/Core/BAO/UFGroup.php @@ -2089,16 +2089,8 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) ); } elseif (substr($fieldName, 0, 4) === 'url-') { - $form->add('text', $name, $title, - array_merge(CRM_Core_DAO::getAttribute('CRM_Core_DAO_Website', 'url'), - array( - 'onfocus' => "if (!this.value) { this.value='http://';} else return false", - 'onblur' => "if ( this.value == 'http://') { this.value='';} else return false", - ) - ), $required - ); - - $form->addRule($name, ts('Enter a valid Website.'), 'url'); + $form->add('text', $name, $title, CRM_Core_DAO::getAttribute('CRM_Core_DAO_Website', 'url'), $required); + $form->addRule($name, ts('Enter a valid web address beginning with \'http://\' or \'https://\'.'), 'url'); } // Note should be rendered as textarea elseif (substr($fieldName, -4) == 'note') { -- 2.25.1