Support empty time range values

Created on 13 August 2019, over 5 years ago
Updated 27 February 2024, 9 months ago

Purpose

  • Support empty time range values

Designed User Experience

  1. A user has already configured a field for time range and is editing content (in my example "event")
  2. When editing the time range field sometimes end times are not known so the user should be able to enter only a start time
  3. Once the user clicks save only the start time should show

Possible Bug Fixed

  • Currently when the user clicks save with only the start time the current time is displayed, this issue will fix this behavior and support empty values
✨ Feature request
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States ccjjmartin Austin, TX

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

Comments & Activities

Not all content is available!

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

  • Status changed to RTBC over 1 year ago
  • πŸ‡¨πŸ‡¦Canada nickdickinsonwilde Victoria, BC (T'So-uke lands)

    Works good and I think the 86401 is a reasonable value

  • πŸ‡§πŸ‡ͺBelgium BramDriesen Belgium πŸ‡§πŸ‡ͺ

    The only thing we are missing now is an automated test to verify this functionality :)

  • πŸ‡­πŸ‡ΊHungary nagy.balint

    I also needed this patch.

    It seems to work fine!

  • πŸ‡§πŸ‡ͺBelgium xaa Brussels

    hi, thank you generalredneck. It seems I also need patch in #10 after a d9.4.8 > d9.5.11 update, possible?

    When trying to access a node the patch from #10 solves the error "InvalidArgumentException: Provided value is out of range. in Drupal\time_field\Time::assertInRange() (line 64 of modules/contrib/time_field/src/Time.php)". The node edit page was also broken (impossible to access/edit the node). Should I open a new ticket for this report ? (as it may need more attention and a higher priority level as the error fully broke the access to the /node/xx/edit page).

  • Assigned to BramDriesen
  • πŸ‡§πŸ‡ͺBelgium BramDriesen Belgium πŸ‡§πŸ‡ͺ

    I'll be trying to make the tests

  • Status changed to Needs work about 1 year ago
  • πŸ‡§πŸ‡ͺBelgium BramDriesen Belgium πŸ‡§πŸ‡ͺ

    Just noticed that this patch actually completely bypasses the field validation. If you set the field as required you can simply save without entering any value at all...

  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update about 1 year ago
    7 pass
  • @bramdriesen opened merge request.
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update about 1 year ago
    11 pass
  • Status changed to Needs review about 1 year ago
  • πŸ‡§πŸ‡ͺBelgium BramDriesen Belgium πŸ‡§πŸ‡ͺ

    Added kernel test

  • Issue was unassigned.
  • Status changed to Fixed about 1 year ago
  • πŸ‡§πŸ‡ͺBelgium BramDriesen Belgium πŸ‡§πŸ‡ͺ
  • Automatically closed - issue fixed for 2 weeks with no activity.

  • Status changed to Fixed 9 months ago
  • πŸ‡³πŸ‡±Netherlands Jan-E

    After the update from 2.1.0 to 2.1.1 I am getting this error during a cron:

    InvalidArgumentException: Provided value is out of range. in Drupal\time_field\Time::assertInRange() (line 64 of modules/contrib/time_field/src/Time.php).

    A few lines of the stack trace:

    #0 modules/contrib/time_field/src/Time.php(145): Drupal\time_field\Time::assertInRange('86401', 0, 86400)
    #1 modules/contrib/time_field/src/Plugin/Field/FieldFormatter/TimeFormatter.php(36): Drupal\time_field\Time::createFromTimestamp('86401')
    #2 modules/contrib/time_field/src/Plugin/Field/FieldFormatter/TimeFormatter.php(47): Drupal\time_field\Plugin\Field\FieldFormatter\TimeFormatter->viewValue(Object(Drupal\time_field\Plugin\Field\FieldType\TimeType))

    Looks like the same error as in #15 ✨ Support empty time range values Fixed . I am running Drupal core 10.2.3.

  • πŸ‡§πŸ‡ͺBelgium BramDriesen Belgium πŸ‡§πŸ‡ͺ

    @Jan-E What is the value you're trying to submit?

  • πŸ‡³πŸ‡±Netherlands Jan-E

    @BramDriessen I really would not know. It also happened when a cron was invoked from outside the site.

  • πŸ‡³πŸ‡±Netherlands Jan-E

    This was the first time it happened, on a time that almost nothing was done on the site:

  • πŸ‡§πŸ‡ͺBelgium BramDriesen Belgium πŸ‡§πŸ‡ͺ

    I've been testing this for a bit but I can't seem to reproduce it :/ if you would happen to be able to debug a bit and see what the values are/where they come from that would help.

  • πŸ‡³πŸ‡±Netherlands Jan-E

    @BramDriesen thanks for getting back on this.

    I just had this once again. Somehow the exact value 86401 gets entered in a time field. When cron runs it apparently tries to clear up the entity cache and falls into the error.

    The previous occasion I remedied it by manually deleting the field instance and the revision instance from the database. I will try to change the value into 86400 now. And will try to find out how users manage to enter 86401.

  • πŸ‡§πŸ‡ͺBelgium BramDriesen Belgium πŸ‡§πŸ‡ͺ

    I think there is someone else with a similar issue in πŸ› After 2.1.1 update all time fields are treated as required; empty values not accepted. Postponed: needs info

Production build 0.71.5 2024