In our testing with our staff, we're finding that many of them are not immediately understanding time selection fields due to the military time selector (outer circle on the clock). Is there any way to display an AM/PM toggle that would allow the staff member to choose either AM or PM instead of using military time?

Military time selector

Comments

attheshow created an issue. See original summary.

Bcwald’s picture

Yeah - So that was something I wanted to set an option for - but unless it fixed in materializecss - I would need to move to a differnet time picker.

The issue is that time picker in materializecss requires the format type="text" where Drupal sets that to "date".

you can see the issue here: https://github.com/Dogfalo/materialize/pull/4882#issuecomment-310851766

attheshow’s picture

I noticed in the docs they mention an option in the Time Picker for "twelveHour Boolean true Use 12 hour AM/PM clock instead of 24 hour clock." Would that be an option?

Bcwald’s picture

StatusFileSize
new544.33 KB

Correct, setting that works OK in the picker itself - however its the inputSubmit format that doesn't get set correctly for type=date. (see gif)

It may be possible to do a function to convert that in the "after select" function.

Bcwald’s picture

Another option would be to use a custom twig template for the time field when 12 hour is selected - which we could change the type to "text", however that could break validation and potentially cause a security risk? Im not sure.

attheshow’s picture

That would be great if we could convert it to match what Drupal is expecting in the way of formatting and use the built-in AM/PM selection. Seems like an ideal solution.

attheshow’s picture

Here's a patch to get this working. This doesn't include the options screen selection that you mentioned and it required that I modify the old 2014 pickadate.js that's included inside this version of materialize.js but this is working well. I'm basically reformatting the selected value into the 24 hour format that Drupal fields are expecting.

attheshow’s picture

Sorry for the empty patch file! Here it is.

attheshow’s picture

Updates patch to fix issue with inability to select 12:00 PM.

attheshow’s picture

Updates patch to fix issue with inability to select 12:00 AM times.