Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
to set the format of the date to the local regions requirements requires that the use of hook_form_alter() to set the #date_format. This patch adds a new dropdown that can be used to set the desired date format.
Comment | File | Size | Author |
---|---|---|---|
#55 | mr-47-changes-for-in-between-dates-2858610-55.patch | 3.48 KB | gueguerreiro |
Issue fork better_exposed_filters-2858610
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
gordon CreditAttribution: gordon as a volunteer commentedthis patch allows you to set the date format via the settings page
Comment #3
mikeker CreditAttribution: mikeker as a volunteer commented@gordon, Thank you for your work on this issue!
A few things to consider:
#date_format
attribute (not sure on this... Need to give it more thought)I'll try to find time to work on this tomorrow.
Comment #4
GRO CreditAttribution: GRO at Realityloop commentedPatch re-roll.
Comment #5
cslevy CreditAttribution: cslevy commentedFor me the patch from #4 wasn't working correctly, so I recreated the patch with a couple of changes
Comment #6
cslevy CreditAttribution: cslevy commentedComment #7
joachim CreditAttribution: joachim at Code Enigma commentedThis patch works, but rather than offering some hardcoded options and a custom textfield, I think we should be using the site's configured date formats (those at admin/config/regional/date-time).
Comment #8
tame4tex CreditAttribution: tame4tex commentedPatch #5 did not include the code to apply the date format settings to a standard Drupal date field. I agree with @joachim that we should be utilizing the site's configured date formats but this patch DOES NOT include that functionality.
Still left to be done:
Comment #9
DanielVezaI took a slightly different approach to this, would be interested to hear feedback.
Instead I made a config form at /admin/config/better_exposed_filters/config that lets you set the date at the m-d-Y or d-m-Y format.
Originally I wanted to set this to use the Drupal date formats, but they don't convert well to the jQuery date formats, and the huge convert code in this module isn't a helper function for some reason (Really should be, issue for another day).
Less flexible per view/datepicker I suppose, but I don't think there should be many reasons to have different datepicker formats on one site.
Comment #10
robin.ingelbrecht CreditAttribution: robin.ingelbrecht at EntityOne commentedWhen installing this patch and afterwards enabling a random module, following error is thrown:
Invalid data type in config better_exposed_filters.config
Comment #11
DanielVezaHmm. Had you saved a date format in the admin UI yet?
It might need a default value or a few more empty checks.. I'll review today/tomorrow when I get some time! I'm using this patch on a few sites and it's working well.
Comment #12
martinadim CreditAttribution: martinadim at Bulcode commentedPatch #9 thrown error
"Invalid data type in config better_exposed_filters.config"
, when saving data type configurations. So changebetter_exposed_filters.config.yml
.Comment #13
DanielVezaAh nice thank you for cleaning that up.
bef_date_format: "\"
I'm not even sure how that got into my patch in #9. Hm. I must have accidently done that when using the Drupal console generator.
Comment #14
robin.ingelbrecht CreditAttribution: robin.ingelbrecht at EntityOne commentedComment #15
imclean CreditAttribution: imclean at Digital Ink commentedBEF 8.x-3.x doesn't really follow Drupal 8 coding styles or guidelines so it may be hard to get this in. Targetting 8.x-4.x may be a better option.
See: #3047739: [Meta] Roadmap to Stable 8.4.x Better Exposed Filters Release
Comment #16
danthorne#12 (patch 17) working for me
Comment #17
imclean CreditAttribution: imclean at Digital Ink commented#7:
Comment #18
imclean CreditAttribution: imclean at Digital Ink commentedThere's also some code commented out. Either remove it or uncomment it and make sure it works.
Comment #19
Etroid CreditAttribution: Etroid commentedI agree we should be using the drupal date formats instead of hardcoding php date formats. This also allows for better localization. Active development is now happening on the 8.x-4.x branch. We should aim to get this patch updated for that version.
Comment #20
darvanenBumping to version 5
Comment #21
Henry Tran CreditAttribution: Henry Tran at Deloitte Digital commentedHi everyone.
I've rerolled #12 to release 5.0-beta1
Cheers
Comment #22
Henry Tran CreditAttribution: Henry Tran at Deloitte Digital commentedHi everyone.
I've rerolled #12 to release 5.0-beta1.
Cheers
Comment #23
StefanieV CreditAttribution: StefanieV commentedI used patch #17 on version 3.0.0-alpha6, which worked.
I have now upgraded to version 5.0.0-beta1 and changed the patch to #22 and I get the error:
Notice: Undefined variable: bef_add_js in Drupal\better_exposed_filters\Plugin\views\exposed_form\BetterExposedFilters->exposedFormAlter() (line 834...).
Comment #24
DimaS11 CreditAttribution: DimaS11 commentedFixed: Notice: Undefined variable: bef_add_js in Drupal\better_exposed_filters\Plugin\views\exposed_form\BetterExposedFilters->exposedFormAlter() (line 834...).
Added: more formats + 'dd.mm.yy' and 'mm.dd.yy'.
Comment #25
DimaS11 CreditAttribution: DimaS11 commentedComment #26
DimaS11 CreditAttribution: DimaS11 commentedComment #27
StefanieV CreditAttribution: StefanieV commented#26 works for me on 5.0.0-beta1 now. Thanks!
Comment #28
V.Hilkov CreditAttribution: V.Hilkov commentedI can also confirm, that #26 is working. I found, that in file BetterExposedFilters.php it adds deprecated core/jquery.ui.datepicker library and better_exposed_filters/datepickers library as well. I don't see why core library should be used, bef datepicker library should have all that is required. I updated patch, only difference is that i removed this deprecated library
Comment #31
svendecabooterI have created a merge request to reroll the last patch for 8.x-5.x and continue work on this.
I started with the patch at #28, with the following improvements:
Comment #32
svendecabooterComment #33
hinal-p CreditAttribution: hinal-p commentedComment #35
hinal-p CreditAttribution: hinal-p commentedI have made changes on patch #28 to make it compatible with the current bef module.
Comment #36
hinal-p CreditAttribution: hinal-p commentedComment #37
jordan.jamous CreditAttribution: jordan.jamous at Eighty Options commentedThanks guys for the efforts.
Continuing the work of @DanielVeza and rerolling #31 with the following enhancement:
phpToJqueryDateFormat()
converter function to reuse Drupal date formatsComment #38
Alina Basarabeanu CreditAttribution: Alina Basarabeanu at Cyber-Duck commentedPatch #37 works for me.
Drupal version 9.4
BEF version 5.2.0
Comment #39
junaidpvDoes patch from #37 really work? jQuery UI Picker always gives the format "m/d/Y" regardless of whatever format I choose in configuration setting.
Drupal: 9.3.13
BEF: 5.2
Comment #40
scuba_fly#37 worked for me.
I needed to go to admin/config/regional/date-time and add a new format for the datepicker
After that I could select it in admin/config/system/better_exposed_filters
Now the datepicker in BEF shows the selected date when I click in the datepicker.
Drupal: 9.4.3
BEF: 5.2
Comment #41
rutiolmaIt works for me but not with all date format patterns.
I noticed that patterns with slashes or spaces/commas, like "d/m/Y" or "l, d F Y" will not work. The only way I could make it work with patch #37 is by using a pattern like "d-m-Y" (plus following the tips provided by scuba_fly on comment 40)
Comment #42
hpower0809 CreditAttribution: hpower0809 as a volunteer commented#37 doesn't seem to work for me either. I added a new date format in the config but it keeps reverting to "m/d/Y"
Drupal: 9.4.8
BEF: 5.2
Comment #43
FiNeX CreditAttribution: FiNeX as a volunteer commentedHi, thanks for the patch. It solves the bug.
Comment #44
Odai AtiehA warning appeared as below, so I've updated the latest patch to check if the filter is set or not before checking if datepicker is selected.
Comment #45
Odai AtiehPlease ignore better_exposed_filters_allow_the_date_format-2858610-23_2.patch
Comment #46
Hotfingers CreditAttribution: Hotfingers commentedHi, I tried #44, but it didn't work.
I had to use #37, but I also had to add a new date format, as @scuba_fly said in #40.
The new format must be set like "19-05-23" as "19/05/23" won't work.
Remember to clear cache.
Drupal: 9.5.5
BEF: 5.2
Comment #47
Alina Basarabeanu CreditAttribution: Alina Basarabeanu commentedUsing Drupal Version 9.5.8, better_exposed_filters version 6.0.3, jquery_ui_datepicker 1.4.0 and patch #44 the date filter is working only with the 'd-m-Y' date format.
Comment #50
DieterHolvoet CreditAttribution: DieterHolvoet at Minsky commentedI started a fresh MR, not based on the previous patches, because I don't really agree with the approach there. Some differences:
strtotime
function were supported.Let's stop posting patches now in order to prevent duplicate work and potential confusion.
Comment #51
DieterHolvoet CreditAttribution: DieterHolvoet at Minsky commentedComment #52
borisson_I really like the latest MR, it is super clear. I made some small remarks in the MR.
Comment #53
DieterHolvoet CreditAttribution: DieterHolvoet at Minsky commentedComment #54
borisson_Thanks @DieterHolvoet!
Comment #55
gueguerreiroMerge request 47 worked perfectly for me, except until I needed to use an in-between date filter, which instead provides multi-date fields (min and max).
The exposedFormAlter() Seems to have special cases for the min/max fields already, but the same does not seem to exist for the exposedFormSubmit() and getElement() functions.
I made some changes to make it work on a project of mine. I'm not sure how to fork from @DieterHolvoet's existing branch, so I'm attaching a patch with the changes (Relative to the MR 47). It can be seen as a diff.
If you could review it and include it on your MR it would be greatly appreciated @DieterHolvoet!
Comment #56
DieterHolvoet CreditAttribution: DieterHolvoet at Minsky commentedThere should be a button at the top of the page saying Get push access. Afterwards click Show commands and you'll get the Git commands necessary to check out the branch locally.
Comment #57
gueguerreiroThank you @DieterHolvoet, I pushed my changes directly to the branch
Comment #58
smustgrave CreditAttribution: smustgrave at Mobomo commentedWill need a post update hook for the schema change.