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

CRM-21523 add form rule for repetition fields in scheduled reminder form #11377

Merged
merged 1 commit into from
Apr 9, 2018
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CRM/Admin/Form/ScheduleReminders.php
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,13 @@ public static function formRule($fields, $files, $self) {
$errors[$recipientKind[$fields['recipient']]['target_id']] = ts('If "Also include" or "Limit to" are selected, you must specify at least one %1', array(1 => $recipientKind[$fields['recipient']]['name']));
}

//CRM-21523
if (!empty($fields['is_repeat']) &&
(empty($fields['repetition_frequency_interval']) || ($fields['end_frequency_interval'] == NULL))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lcdservices because you used == instead of === I don't think those two conditions are actually different.
Php thinks that 0 == NULL but not 0 === NULL.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that it seems like we should use the strict operator, but it doesn't work when you do. I believe that's because the values we receive are cast as strings, not integers. If we use the strict operator an empty value for the end_frequency_interval field does not trigger the validation.

) {
$errors['is_repeat'] = ts('If you are enabling repetition you must indicate the frequency and ending term.');
}

$actionSchedule = $self->parseActionSchedule($fields);
if ($actionSchedule->mapping_id) {
$mapping = CRM_Core_BAO_ActionSchedule::getMapping($actionSchedule->mapping_id);
Expand Down
4 changes: 2 additions & 2 deletions templates/CRM/Admin/Form/ScheduleReminders.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@
<tr id="repeatFields" class="crm-scheduleReminder-form-block-repeatFields"><td></td><td>
<table class="form-layout-compressed">
<tr class="crm-scheduleReminder-form-block-repetition_frequency_interval">
<td class="label">{$form.repetition_frequency_interval.label}&nbsp;&nbsp;&nbsp;{$form.repetition_frequency_interval.html}</td>
<td class="label">{$form.repetition_frequency_interval.label} <span class="crm-marker">*</span>&nbsp;&nbsp;{$form.repetition_frequency_interval.html}</td>
<td>{$form.repetition_frequency_unit.html}</td>
</tr>
<tr class="crm-scheduleReminder-form-block-repetition_frequency_interval">
<td class="label">{$form.end_frequency_interval.label}&nbsp;&nbsp;&nbsp;{$form.end_frequency_interval.html}
<td class="label">{$form.end_frequency_interval.label} <span class="crm-marker">*</span>&nbsp;&nbsp;{$form.end_frequency_interval.html}
<td>{$form.end_frequency_unit.html}&nbsp;&nbsp;&nbsp;{$form.end_action.html}&nbsp;&nbsp;&nbsp;{$form.end_date.html}</td>
</tr>
</table>
Expand Down