We configured our "Hours Minutes and Seconds" field to use "Natural language" (Administration > Structure > Content types > [name of content type] >> Manage display). When we did this, the node view didn't display the value of the field. In addition, we encountered the following errors:

Notice: Undefined offset: 0 in _hms_seconds_to_formatted() (line 541 of [redacted]\sites\all\modules\hms_field\hms_field.module).
Notice: Undefined offset: 1 in _hms_seconds_to_formatted() (line 541 of [redacted]\sites\all\modules\hms_field\hms_field.module).
Notice: Undefined offset: 2 in _hms_seconds_to_formatted() (line 541 of [redacted]\sites\all\modules\hms_field\hms_field.module).
Notice: Undefined offset: 3 in _hms_seconds_to_formatted() (line 541 of [redacted]\sites\all\modules\hms_field\hms_field.module).
Notice: Undefined offset: 4 in _hms_seconds_to_formatted() (line 541 of [redacted]\sites\all\modules\hms_field\hms_field.module).

Weirdly, we used "Natural language" on two different content types. Both initially produced the same errors. Now, event though the two "Hours Minutes and Seconds" fields are both configured exactly the same (including the Manage display settings), one field works fine now, while the other continues to have the problems mentioned above. It's almost like saving the configuration in a certain order caused one of them to work; but who knows what sequence of events got us there.

Comments

slanger created an issue. See original summary.

slanger’s picture

Status: Active » Needs review
StatusFileSize
new751 bytes

This patch fixed the problem for us.

Here's what we uncovered: On line 137 of hms_field.module, "display_formats" is set as an array, which contains the format tokens. However, on line 258, rather than using the value of the array elements ('w', 'd', 'h', 'm', 's'), it uses the keys instead (0, 1 , 2, 3, 4), resulting in the errors I listed previously.

Status: Needs review » Needs work

The last submitted patch, 2: hms_field-natural-lang-format-error-2657228.patch, failed testing.

slanger’s picture

Issue summary: View changes

The last submitted patch, 2: hms_field-natural-lang-format-error-2657228.patch, failed testing.

ssimdev’s picture

Status: Needs work » Patch (to be ported)

I tested the patch and works fine.

  • msajko committed b987b02 on 7.x-1.x authored by slanger
    Issue #2657228 by slanger: Natural language: Display format errors
    
msajko’s picture

Status: Patch (to be ported) » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.