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

COMCL-640: Ensure submit buttons will validate the form properly #1026

Merged
merged 1 commit into from
Aug 8, 2024

Conversation

olayiwola-compucorp
Copy link

Overview

This PR addresses an issue where users are unable to create a new communication type activity under the contacts form New Activity. The problem occurs due to the Draft button being added to the New Activity form, which introduces a new button ID that is not accounted for in CiviCRM's form validation process.

$buttonGroup = $form->getElement('buttons');
$buttons = $buttonGroup->getElements();
$buttons[] = $form->createElement(
'xbutton',
$form->getButtonName('refresh'),
ts('Save Draft'), [
'type' => 'submit',
'crm-icon' => 'fa-pencil-square-o',
'class' => 'crm-form-submit',
]
);
$buttonGroup->setElements($buttons);
$form->addGroup($buttons, 'buttons');
$form->setDefaults(['status_id' => 2]);
}

After adding the button in the hook above, the new button ID is not catered for in CiviCRM https://github.com/civicrm/civicrm-core/blob/920907161e991952f07eb4b73910886022e8c414/templates/CRM/Core/Form/RecurringEntity.tpl#L209 where submit buttons are not expected to validate unchanged elements.

Before

Users were unable to create activities under the contacts forms New Activity.

22111ere111

After

Users can now successfully create activities under the contacts forms New Activity.

111ere111

Technical Implementation

The fix involves adding a new hook_civicrm_alterContent() implementation in civicase.php. This hook modifies the content of the Activity form template to include all relevant button IDs for proper form validation.

@olayiwola-compucorp olayiwola-compucorp merged commit 06c2ae4 into 4.2.0-dev Aug 8, 2024
2 checks passed
@olayiwola-compucorp olayiwola-compucorp deleted the COMCL-640-fix-activity branch August 8, 2024 05:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants