-
Notifications
You must be signed in to change notification settings - Fork 25
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
Use addDatePickerRange
instead of deprecated/removed addDateRange()
for forms
#181
Conversation
'donrec_contribution_horizon', | ||
E::ts('Time period'), | ||
FALSE, | ||
FALSE, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As pointed out in the PR summary, setting this to TRUE
causes all sub-fields be required, which makes selecting relative date options impossible.
'_to', | ||
'_from', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those are _low
and _high
by default, thus we have to pass the traditional field names here.
$values['donrec_contribution_horizon_from'], | ||
$values['donrec_contribution_horizon_to'] | ||
); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This processes relative dates and formats from
and to
values with YmdHiS
, unfortunately, that's why we have to re-format again below.
$date_from = CRM_Utils_DonrecHelper::convertDate($raw_from_ts, -1, 'YmdHis'); | ||
$date_to = CRM_Utils_DonrecHelper::convertDate($raw_to_ts, 1, 'YmdHis'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not change the parameter's default value in the signature, although it does not seem to be called from anywhere else than here.
addDatePickerRange
instead of deprecated(removed addDateRange()
for formsaddDatePickerRange
instead of deprecated/removed addDateRange()
for forms
I have just changed the files in my installation, so it is only quick and dirty, but I still get an exception:
Do I have to run an upgrader or delete sth? |
Please note that you should not include versions in your extension directory names ( |
07738b0
to
0bcd2a3
Compare
I've tested the changes again after the rebase and it looks good. |
Released with version |
Fixes #138.
This replaces the custom-built date range selector fields in task forms with
addDatePickerRange()
as suggested by the deprecation notice, making custom JS code for translating custom relative date options into actual date values unnecessary.This effectively adds all available date range options and uses
CRM_Utils_Date::getFromTo()
for converting relative dates (previous fiscal year etc.) into from and to values to work with the extension's current query building.Note that the date picker element can apparently not be made
required
, as all sub-fields would be required effectively (_from
,_to
,_relative
). Maybe there should be additional validation for that …?I'd appreciate some functional review (maybe by @jojowork?) and a code-one (@bjendres?).
systopia-reference: 23334