Problem/Motivation

Numeric fields are meant to have a "content=value" attribute set on the field-item when a prefix or suffix is added to the number for display. This attribute will currently not be added when the field-item doesn't contain other attributes. It is irrelevant whether there are other attributes or not, so the test should be changed.

Steps to reproduce

  1. Standard Install of Drupal
  2. Add a Number (integer) field to the Article content type
  3. Configure the field to have a prefix
  4. Create content with a number in the integer field and notice that the markup is missing the "content=value" attribute on the field-item wrapper around the number

Proposed resolution

I think the intention was to make sure the _attribute property is set before adding to it. Instead of if (!empty($item->_attributes) ... replace with if (isset($item->_attributes)....

After the patch, the correct markup is output as shown in the screenshot.

Remaining tasks

Review patch.

User interface changes

None.

API changes

None

Data model changes

None

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ShaunDychko’s picture

Status: Active » Needs review
FileSize
837 bytes
8.75 KB
Anonymous’s picture

Looks like a reasonable patch to me.

HeimdallJHM’s picture

Tested. As you can see in the attached images the patch works

HeimdallJHM’s picture

Status: Needs review » Reviewed & tested by the community
alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

This should be tested.

ShaunDychko’s picture

Assigned: Unassigned » ShaunDychko
ShaunDychko’s picture

Automated tests added. I included a patch with new tests only, one of which fails as expected, and then included a combined patch with both the new tests and the fix (following https://www.drupal.org/contributor-tasks/write-tests).

The last submitted patch, 7: 2537288-attribute-for-numeric-tests.patch, failed testing.

segi’s picture

I reviewed the patch and it gives the necessary content attribute to DOM. I think the patch is correct, I found a little problem which is maybe only problem for me, but I think one variable name "$the_value" is not too clear what it contains so I changed it to $integer_value.

ShaunDychko’s picture

Status: Needs review » Reviewed & tested by the community

Screenshots in #3, review/slight revision of tests in #9. RTBC.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 9: 2537288-attribute-for-numeric-8.patch, failed testing.

subhojit777’s picture

Status: Needs work » Needs review

Seems to me like a random failure. Invoking the bot again.

ShaunDychko’s picture

Status: Needs review » Reviewed & tested by the community

Passes again, so setting back to RTBC.

ShaunDychko’s picture

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed e249d75 and pushed to 8.0.x. Thanks!

  • alexpott committed e249d75 on 8.0.x
    Issue #2537288 by ShaunDychko, segi, HeimdallJHM: Content=Value...

Status: Fixed » Closed (fixed)

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