Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
First thing is if you try to save node with required scheduler field with a blank time field then you will have same error:
The value input for field Unpublish on is invalid:
The value 2012-09-26 does not match the expected format.
We are really didn't use 'Time' field, because of this I tried to hide it into scheduler settings:
But I have got an error:
Comment | File | Size | Author |
---|
Comments
Comment #1
mrded CreditAttribution: mrded commentedComment #2
mrded CreditAttribution: mrded commentedComment #3
mrded CreditAttribution: mrded commentedPlease, check my patch.
Comment #4
gaheinrichs CreditAttribution: gaheinrichs commentedI checked your patch. It work for me really well. Thanks!
Comment #5
mrded CreditAttribution: mrded commentedComment #6
jonathan1055 CreditAttribution: jonathan1055 commentedHello,
The first part of the patch looks good, ie only validate the time format if some time letter elements have been entered.
But I am not sure about the second part, when you say the $date_format is valid if it matches SCHEDULER_DATE_FORMAT or the hard-coded value 'Y-m-d'. If you need to use 'Y-m-d' then that value should be allowed in SCHEDULER_DATE_FORMAT.
Or maybe I am missing the point. But I do not think that Eric would like to hard-code a vaidation value, there should be a clearer way to do it.
Good work, though. This does need to be changed. Haven't we seen this issue or something like it before?
Jonathan
Comment #7
jonathan1055 CreditAttribution: jonathan1055 commentedHi,
I have looked at this in more detail, and I think there might be a better solution. There should be no reason why we cannot set 'Y-m-d' as the scheduler format setting and still use date_popup with no trouble. The value is set in #date_format in the popup field settings and everything should just flow through. However, I think the reason it was not done like that in Scheduler is due to a slight bug in the date_pop module where it always returns the string in its own standard format Y-m-d H:i:s regardless of what you have requested in #date_format. So in scheduler we had to use exactly that format. You were managing to get away with it by luck because your date format matched the first part of this.
I have raised an issue with date_pop #1855810: Define #return_value_format for date_popup to set the form value. If that is resolved then we can simply allow Y-m-d as the value of scheduler_date_format for both popup and non-popup options and not have to reset date_format in _scheduler_strtotime(). This will also be more flexible because it will allow others formats for the date part of the datetime, eg d-m-Y H:i:s which currently would fail in scheduler (so we do not allow it).
This will also simplify some of the code where we use $internal_date_format but that can wait until later.
Thanks for starting this discussion. I hope that the date_popup issue can be implemented (it is only a one-line correction) then we'll code the scheduler change.
Jonathan
Comment #8
jonathan1055 CreditAttribution: jonathan1055 commentedWhen we have committed #1069668: Default time with user override then the solution for removing the time entry box as requested above is almost trivial. It only requires your very first change:
Two additional benefits of this combined solution are (1) the Admin can set the default time which does not need to be 00:00:00 and (2) we do not need to wait for the date_popup fix #1855810: Define #return_value_format for date_popup to set the form value.
When making this change, we could also improve the text of the validation message, by add 'time' in front of 'formats'
Jonathan
Comment #9
jonathan1055 CreditAttribution: jonathan1055 commentedThe code change above to cater for empty time formats was included in #1069668: Default time with user override hence this issue can be closed as a the functionality is now available.
Also see #2123103: Allow more popup formats which further enhances the flexibility of times in date_popup.