From f70833347b8961a9d549f333b614dcbca4a04445 Mon Sep 17 00:00:00 2001 From: Andrew Hunt Date: Thu, 6 Aug 2020 13:55:52 -0400 Subject: [PATCH] Give buttons a value when the submitted value is used to identify them --- CRM/Admin/Form/Preferences/Display.php | 5 ++++- CRM/Batch/Form/Entry.php | 5 ++++- CRM/Contact/Form/Task/AddToParentClass.php | 1 + CRM/Core/BAO/Mapping.php | 2 ++ CRM/Core/Form.php | 7 +++++++ CRM/Event/Form/ManageEvent/Fee.php | 1 + CRM/Profile/Form/Edit.php | 5 ++++- 7 files changed, 23 insertions(+), 3 deletions(-) diff --git a/CRM/Admin/Form/Preferences/Display.php b/CRM/Admin/Form/Preferences/Display.php index c251b45020..af824f1f02 100644 --- a/CRM/Admin/Form/Preferences/Display.php +++ b/CRM/Admin/Form/Preferences/Display.php @@ -54,7 +54,10 @@ class CRM_Admin_Form_Preferences_Display extends CRM_Admin_Form_Preferences { 'xbutton', 'ckeditor_config', CRM_Core_Page::crmIcon('fa-wrench') . ' ' . ts('Configure CKEditor'), - ['type' => 'submit'] + [ + 'type' => 'submit', + 'value' => 1, + ] ); $editOptions = CRM_Core_OptionGroup::values('contact_edit_options', FALSE, FALSE, FALSE, 'AND v.filter = 0'); diff --git a/CRM/Batch/Form/Entry.php b/CRM/Batch/Form/Entry.php index 8e1a3022f4..ceb3868d28 100644 --- a/CRM/Batch/Form/Entry.php +++ b/CRM/Batch/Form/Entry.php @@ -176,7 +176,10 @@ class CRM_Batch_Form_Entry extends CRM_Core_Form { $this->addElement('xbutton', $forceSave, ts('Ignore Mismatch & Process the Batch?'), - ['type' => 'submit'] + [ + 'type' => 'submit', + 'value' => 1, + ] ); $this->addButtons([ diff --git a/CRM/Contact/Form/Task/AddToParentClass.php b/CRM/Contact/Form/Task/AddToParentClass.php index ac69e5e142..aee54878d4 100644 --- a/CRM/Contact/Form/Task/AddToParentClass.php +++ b/CRM/Contact/Form/Task/AddToParentClass.php @@ -68,6 +68,7 @@ class CRM_Contact_Form_Task_AddToParentClass extends CRM_Contact_Form_Task { $buttonAttrs = [ 'type' => 'submit', 'class' => 'crm-form-submit', + 'value' => 1, ]; $this->addElement('xbutton', $this->getButtonName('refresh'), ts('Search'), $buttonAttrs); $this->addElement('xbutton', $this->getButtonName('cancel'), ts('Cancel'), $buttonAttrs); diff --git a/CRM/Core/BAO/Mapping.php b/CRM/Core/BAO/Mapping.php index 58b573c3f8..3c9bf18bea 100644 --- a/CRM/Core/BAO/Mapping.php +++ b/CRM/Core/BAO/Mapping.php @@ -322,6 +322,7 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { [ 'type' => 'submit', 'class' => 'submit-link', + 'value' => 1, ] ); @@ -559,6 +560,7 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { $form->addElement('xbutton', "addMore[$x]", ts('Another search field'), [ 'type' => 'submit', 'class' => 'submit-link', + 'value' => 1, ]); } //end of block for diff --git a/CRM/Core/Form.php b/CRM/Core/Form.php index 610ea053c6..ef81439d24 100644 --- a/CRM/Core/Form.php +++ b/CRM/Core/Form.php @@ -668,6 +668,13 @@ class CRM_Core_Form extends HTML_QuickForm_Page { $attrs = ['class' => 'crm-form-submit'] + (array) CRM_Utils_Array::value('js', $button); + // A lot of forms use the hacky method of looking at + // `$params['button name']` (dating back to them being inputs with a + // "value" of the button label) rather than looking at + // `$this->controller->getButtonName()`. It makes sense to give buttons a + // value by default as a precaution. + $attrs['value'] = 1; + if (!empty($button['class'])) { $attrs['class'] .= ' ' . $button['class']; } diff --git a/CRM/Event/Form/ManageEvent/Fee.php b/CRM/Event/Form/ManageEvent/Fee.php index 78fdadaf62..fa96e1a4f6 100644 --- a/CRM/Event/Form/ManageEvent/Fee.php +++ b/CRM/Event/Form/ManageEvent/Fee.php @@ -359,6 +359,7 @@ class CRM_Event_Form_ManageEvent_Fee extends CRM_Event_Form_ManageEvent { [ 'type' => 'submit', 'class' => 'crm-form-submit cancel', + 'value' => 1, ] ); if (Civi::settings()->get('deferred_revenue_enabled')) { diff --git a/CRM/Profile/Form/Edit.php b/CRM/Profile/Form/Edit.php index 16bc4a31eb..758e971127 100644 --- a/CRM/Profile/Form/Edit.php +++ b/CRM/Profile/Form/Edit.php @@ -209,7 +209,10 @@ SELECT module,is_reserved if (($this->_multiRecord & CRM_Core_Action::DELETE) && $this->_recordExists) { $this->_deleteButtonName = $this->getButtonName('upload', 'delete'); - $this->addElement('xbutton', $this->_deleteButtonName, ts('Delete'), ['type' => 'submit']); + $this->addElement('xbutton', $this->_deleteButtonName, ts('Delete'), [ + 'type' => 'submit', + 'value' => 1, + ]); return; } -- 2.25.1