Allow the date format to be set from the BEF interface

Created on 8 March 2017, over 7 years ago
Updated 9 June 2024, 19 days ago

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.

✨ Feature request
Status

Closed: outdated

Version

7.0

Component

Code

Created by

🇦🇺Australia gordon Melbourne

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇯🇴Jordan Odai Atieh Amman

    A 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.

    Warning: Undefined array key "filter" in Drupal\better_exposed_filters\Plugin\views\exposed_form\BetterExposedFilters->exposedFormAlter() (line 797 of modules/contrib/better_exposed_filters/src/Plugin/views/exposed_form/BetterExposedFilters.php).
    
  • 🇯🇴Jordan Odai Atieh Amman

    Please ignore better_exposed_filters_allow_the_date_format-2858610-23_2.patch

  • 🇮🇹Italy Hotfingers

    Hi, 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

  • 🇬🇧United Kingdom Alina Basarabeanu

    Using 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.

  • First commit to issue fork.
  • Status changed to Needs work 9 months ago
  • 🇧🇪Belgium DieterHolvoet Brussels

    I started a fresh MR, not based on the previous patches, because I don't really agree with the approach there. Some differences:

    • A lot simpler, less code.
    • No global module config is added. The date format is stored in the filter widget config instead.
    • Every date format is now compatible. Before, only formats that were parseable by the strtotime function were supported.

    Let's stop posting patches now in order to prevent duplicate work and potential confusion.

  • Status changed to Needs review 9 months ago
  • 🇧🇪Belgium DieterHolvoet Brussels
  • Status changed to Needs work 8 months ago
  • 🇧🇪Belgium borisson_ Mechelen, 🇧🇪

    I really like the latest MR, it is super clear. I made some small remarks in the MR.

  • Status changed to Needs review 8 months ago
  • 🇧🇪Belgium DieterHolvoet Brussels
  • Status changed to RTBC 8 months ago
  • 🇧🇪Belgium borisson_ Mechelen, 🇧🇪

    Thanks @DieterHolvoet!

  • Status changed to Needs review 7 months ago
  • 🇵🇹Portugal gueguerreiro Lisboa

    Merge 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!

  • 🇧🇪Belgium DieterHolvoet Brussels

    I'm not sure how to fork from @DieterHolvoet's existing branch

    There 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.

  • 🇵🇹Portugal gueguerreiro Lisboa

    Thank you @DieterHolvoet, I pushed my changes directly to the branch

  • Status changed to Needs work 3 months ago
  • 🇺🇸United States smustgrave

    Will need a post update hook for the schema change.

  • First commit to issue fork.
  • Pipeline finished with Success
    about 2 months ago
    Total: 263s
    #165576
  • 🇹🇷Turkey Orkut Murat Yılmaz

    Any updates on this?

  • 🇺🇸United States smustgrave

    Still appears to need a post update hook.

  • Pipeline finished with Success
    29 days ago
    Total: 216s
    #185761
  • 🇧🇪Belgium svendecabooter Gent

    The MR seems broken since the changes in 📌 Remove dependency on jquery_ui_datepicker Needs work .
    JQuery UI datepicker library seems to be removed since release 6.0.6.
    So the MR should be updated, to be able to set the desired date format in another way.

  • 🇧🇪Belgium StryKaizer Belgium

    This patch does not apply anymore indeed.
    Since 6.0.6 uses the native date element, the localization of date formats already works out of the box (using browser settings), making this feature (controlling the exact format) a bit less necessary for most use-cases.

  • Status changed to Postponed: needs info 22 days ago
  • 🇺🇸United States smustgrave

    So question is this needed by anyone anymore with removal of jquery?

  • 🇧🇪Belgium DieterHolvoet Brussels

    I just tried out 7.0.0-beta1. For me personally this issue can be closed, since the browser now automatically uses a localized date format for the date picker.

  • Status changed to Closed: outdated 19 days ago
  • 🇺🇸United States smustgrave

    Thanks everyone that worked on this. Does seem to no longer be needed with removal of jquery.

Production build 0.69.0 2024