Problem/Motivation
The isEmpty method (\Drupal\office_hours\Element\OfficeHoursDatetime::isEmpty) fails on a -1 value. It checks for a string '-1' but sometimes it gets the -1 integer and doesn't mark that as empty.
Steps to reproduce
(using the dev release) I added a field to a node, with the exceptions. After adding an item and exception, I re-edited the node and removed the exception. Upon saving, there are a lot of form-errors: This value should be of the correct primitive type.
Proposed resolution
Change the check to if ((int) $element === -1) { ... }
Remaining tasks
-
User interface changes
-
API changes
-
Data model changes
-
Issue fork office_hours-3253749
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3253749-isempty-check-fails changes, plain diff MR !7
Comments
Comment #3
johnvComment #4
johnvComment #6
johnvThanks, fixed in a slightly different version.
Comment #9
johnvComment #11
johnvThe tests/src/Unit/OfficeHoursDatetimeUnitTest.php was fixed in above commit.