Closed (fixed)
Project:
Smart Date
Version:
3.7.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
29 Jul 2022 at 16:34 UTC
Updated:
27 Jan 2023 at 10:59 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
joewhitsittThe min and max attributes are only set when the field has a value (e.g. default value)
docroot/core/lib/Drupal/Core/Datetime/Element/Datetime.php - processDatetime()
Comment #3
joewhitsittComment #4
joewhitsittAdding reference to core issue for similar functionality
Comment #5
mandclu commentedBased on my own (admittedly limited) investigation, it seems as though we should be able to set #min and #max values, in addition to #date_year_range. Personally I'd prefer the two former (provided they actually work) as it sounds like they could provide more granular control, for example with a DrupalCamp restricting sessions to be scheduled during the days the camp actually runs.
Comment #7
mandclu commentedI ended up implementing this not as much in the widget configuration but in the field settings. Will open a child issues around adding a validation constraint so these can also be enforced when creating values programmatically, and also to make sure that these are respected for recurring values.
Will likely roll this into a beta release.
Comment #8
joewhitsittThanks for this @mandclu. We will revisit our workaround when this is released.
Comment #9
mandclu commentedThis has been included in the most recent release.
Comment #11
joewhitsitt@mandclu
I finally got a chance to look at this along with the schema commit and I am getting undefined array key min and max related to the "next hour" default functionality here if I leave the min and max blank like the help text says (not required).
https://git.drupalcode.org/project/smart_date/-/commit/4aa93f7#39ea69cdc...
When the min and max are set, instead of the next hour (today plus one hour), it defaults to the max limit (set as 2037-12-31) plus one hour. I think that is because of a typo
Should be:
Comment #12
mandclu commentedAh good catch. Did you test if it works as expected with that change?
Comment #13
joewhitsittI did in that very specific situation. Haven't had a moment to submit an MR and wasn't sure if it should be a separate issue
Comment #14
jrockowitz commentedHere is a quick fix
Comment #15
joewhitsittThanks @jrockowitz
I created an MR to cover both the if not empty check and the only if greater than max check.
Comment #17
mandclu commentedThanks for everyone's work on this. The latest changes are merged into the 3.6.x and 3.7.x branches.