Support from Acquia helps fund testing for Drupal Acquia logo

Comments

gordon created an issue. See original summary.

gordon’s picture

Assigned: Unassigned » gordon
Status: Active » Needs review
FileSize
3.24 KB

There seems to be a lot issues which stopped everything from working.

  1. The path to the element looks like it has not been changed to work with d8, it was looking for the value element which is not present in d8.
  2. When it was detecting the date field it was looking for the date_text field which is from the d7 date module which is in core in d8.
  3. The parameter name was set to dateformat when it needs to be dateFormat
  4. lastly the bef_datepicker.js was expecting all the options to be JSON parsed. I think it must be a d7 thing. I have just fixed, but I think that it can be changed so it isn't looping through all the elements .
gordon’s picture

Doing some more investigation on this I found that the date element \Drupal\views\Plugin\views\filter\Date::validateValidTime() only uses strtotime() to convert the string to a timestamp. So in using the date format of d/m/Y will not work as strtotime() will treat it as a m/d/Y format, so you need to use d-m-Y

grumpy74’s picture

@gordon

Thanks for pointing this. I have the same issue. How do you change the date picker format ?

ariane’s picture

@grumpy74

Maybe late but I wish I could help anyone else..

1) go to /admin/config/regional/translate
2) search the string mm/dd/yy
3) translate to dd-mm-yy
4) save and flush caches
5) try to search a date

It worked for me! Thanks @gordon !!

grumpy74’s picture

@ariane, thank you for the answer.

ericdsd’s picture

Thanks,
translating mm/dd/yy to dd-mm-yy
worked for me too
Note that translating to dd/mm/yy does not.

Radelson’s picture

Rerolled the patch for this issue against 5.0.0-beta1

I don't quite understand how the #date_format is supposed to be set without custom code but when it's there, it seems to work.

Neslee Canil Pinto’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

Patch needs reroll

ankithashetty’s picture

Status: Needs work » Needs review
FileSize
2.92 KB
0 bytes

Re-rolled the patch in #8. Kindly review.

Thank you!

ankithashetty’s picture

FileSize
2.4 KB
Neslee Canil Pinto’s picture

Version: 8.x-3.x-dev » 8.x-5.x-dev
javitan’s picture

Fixed patch including reroll. :D

Remember: After apply the patch you will need to add into MYMODULE_form_views_exposed_form_alter(&$form, FormStateInterface $form_state, $form_id) the new format. Example:

$form['MYDATEFIELD']['#attached']['drupalSettings']['better_exposed_filters']['datepicker_options']['dateFormat'] = 'dd/mm/yy';

Enjoy and good luck!

javitan’s picture

Without the patch, it is working just doing: $form['MYDATEFIELD']['#attached']['drupalSettings']['better_exposed_filters']['datepicker_options']['dateFormat'] = json_encode('dd/mm/yy'); on MYMODULE_form_views_exposed_form_alter() function.

Cheers! :D

igonzalez’s picture

#14 works for me

Neslee Canil Pinto’s picture

Assigned: gordon » Unassigned
Status: Needs review » Fixed

This can be fixed using #14, marking as fixed.

ericdsd’s picture

Hi @Neslee Canil Pinto maybe i'm wrong but don't you think we should fix the root cause instead of considering that having a workaround is fixing the issue ?
I propose to reopen the issue what do you think ?

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

viola_chisto’s picture

@Gordon and @ariane, #5 did the trick ! Thank so much I was breaking my head !