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

CiviEvent - Fix missing default values for required fields in event registration setup #25410

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 11 additions & 9 deletions CRM/Event/Form/ManageEvent/Registration.php
Expand Up @@ -116,8 +116,7 @@ public function setDefaultValues() {
$defaults["custom_post_id_multiple[$key]"] = $value;
}
}

$this->assign('profilePostMultiple', CRM_Utils_Array::value('custom_post', $defaults));
$this->assign('profilePostMultiple', $defaults['custom_post'] ?? NULL);

// CRM-17745: Make max additional participants configurable
if (empty($defaults['max_additional_participants'])) {
Expand Down Expand Up @@ -149,7 +148,7 @@ public function setDefaultValues() {
$defaults["additional_custom_post_id_multiple[$key]"] = $value;
}
}
$this->assign('profilePostMultipleAdd', CRM_Utils_Array::value('additional_custom_post', $defaults, []));
$this->assign('profilePostMultipleAdd', $defaults['additional_custom_post'] ?? []);
}
else {
// Avoid PHP notices in the template
Expand All @@ -161,10 +160,10 @@ public function setDefaultValues() {
}

// provide defaults for required fields if empty (and as a 'hint' for approval message field)
$defaults['registration_link_text'] = CRM_Utils_Array::value('registration_link_text', $defaults, ts('Register Now'));
$defaults['confirm_title'] = CRM_Utils_Array::value('confirm_title', $defaults, ts('Confirm Your Registration Information'));
$defaults['thankyou_title'] = CRM_Utils_Array::value('thankyou_title', $defaults, ts('Thank You for Registering'));
$defaults['approval_req_text'] = CRM_Utils_Array::value('approval_req_text', $defaults, ts('Participation in this event requires approval. Submit your registration request here. Once approved, you will receive an email with a link to a web page where you can complete the registration process.'));
$defaults['registration_link_text'] = $defaults['registration_link_text'] ?? ts('Register Now');
$defaults['confirm_title'] = $defaults['confirm_title'] ?? ts('Confirm Your Registration Information');
$defaults['thankyou_title'] = $defaults['thankyou_title'] ?? ts('Thank You for Registering');
$defaults['approval_req_text'] = $defaults['approval_req_text'] ?? ts('Participation in this event requires approval. Submit your registration request here. Once approved, you will receive an email with a link to a web page where you can complete the registration process.');

return $defaults;
}
Expand Down Expand Up @@ -442,10 +441,13 @@ public function addRules() {
public static function formRule($values, $files, $form) {
if (!empty($values['is_online_registration'])) {

if (!$values['confirm_title']) {
if (($values['registration_link_text'] ?? '') === '') {
$errorMsg['registration_link_text'] = ts('Please enter Registration Link Text');
}
if (($values['confirm_title'] ?? '') === '') {
$errorMsg['confirm_title'] = ts('Please enter a Title for the registration Confirmation Page');
}
if (!$values['thankyou_title']) {
if (($values['thankyou_title'] ?? '') === '') {
$errorMsg['thankyou_title'] = ts('Please enter a Title for the registration Thank-you Page');
}
if ($values['is_email_confirm']) {
Expand Down
2 changes: 1 addition & 1 deletion templates/CRM/Event/Form/ManageEvent/Registration.tpl
Expand Up @@ -50,7 +50,7 @@

<tr class="crm-event-manage-registration-form-block-registration_link_text">
<td scope="row" class="label"
width="20%">{$form.registration_link_text.label} {if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_event' field='registration_link_text' id=$eventID}{/if}</td>
width="20%">{$form.registration_link_text.label} <span class="crm-marker">*</span>{if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_event' field='registration_link_text' id=$eventID}{/if}</td>
<td>{$form.registration_link_text.html} {help id="id-link_text"}</td>
</tr>
{if !$isTemplate}
Expand Down
Expand Up @@ -16,6 +16,7 @@ private function getCorrectFormFields() {
'is_email_confirm' => 0,
'confirm_title' => 'Confirm your registration',
'thankyou_title' => 'Thank you for your registration',
'registration_link_text' => 'Register Now',
];
}

Expand Down