Product variation text field leading zeros

Created on 29 August 2023, about 1 year ago
Updated 4 October 2023, about 1 year ago

Could not update text field value with leading zeros.

Text field used for EAN.

Steps to reproduce

  • Add Text (plain) field to product variation entity.
  • Create new product variation and set field value 1234567890.
  • Update product variation and set field value 0001234567890.
  • Field value is still 1234567890.
🐛 Bug report
Status

Needs review

Version

2.28

Component

Product

Created by

🇨🇿Czech Republic Xperd

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

Comments & Activities

  • Issue created by @Xperd
  • Assigned to viren18febS
  • 🇮🇳India viren18febS

    Checking the issue!

  • Issue was unassigned.
  • Status changed to Needs review about 1 year ago
  • 🇮🇳India viren18febS

    Hi @Xperd

    For EAN number in text field you need to use a specific validations, you can use Field Validation module. in this we have specific configurations for EAN validation. Or you can use hook_form_alter() for applied a custom validation on that field.

  • Status changed to Active about 1 year ago
  • 🇨🇿Czech Republic Xperd

    I don't need validation.

    It is not possible change text field value from 1234567890 to 0001234567890.

  • Status changed to Needs review about 1 year ago
  • 🇮🇳India viren18febS

    I am able to set both values in text field, not getting any issue. attached screen shot for your reference.

  • 🇺🇸United States aaustin

    I've come to this issue looking for answers about leading zeros in the core string field, where this exact thing is happening (9.5.11). The issue also appears in the address field: https://www.drupal.org/project/address/issues/3017352 I think the important information is that if the value is currently set to a number and you change it to the same number but with leading zeros it doesn't update. Likewise, it doesn't work going from leading zeros to no leading zeros or two leading zeros to four leading zeros, etc. You can change it to something else (that isn't the numerically equivalent) and then change it to the value with leading zeros and it works. But there seems to be something in Drupal core that doesn't update a field when you the value is the same integer but different strings.

Production build 0.71.5 2024