- Issue created by @sidgrafix
- πΊπΈUnited States sidgrafix
Well.. I found the cause of the problem.
It is directly related to setting the computed fields "maximum length" (The maximum length of the field in characters) during field creation. I matched the max length of the default text field of 12 (which always worked fine and displayed properly) for the computed field (which drops the last digit/character). It appears if a value for a computed field is the number of characters that is the max allowed by the computed field, on render it will drop the last digit/character and only save and display 11 characters.
I ran 3 tests to confirm this:
First I created a new computed text field and left it set to default of 255 for maximum length, and the correct 12 digits/characters rendered in the computed field.
Second I created another computed text field and set it's max length to 13, again the correct 12 digits/characters displayed.
Third I created another computed text field and set its max length to 12 (same as one of the original computed fields I had set) and this time like before only 11 digits/characters displayed... which is not correct.So this is obviously a bug! Considering I have a regular text field that has a max character length of 12 (and it accepts and displays 12 characters/digits without issue) a computed field set the same should also display all 12 digits/characters and does not. For whatever reason it is only rendering with 11 characters and provides no errors or notices when it probably should.
I think the field storage of the value is correct (if I edit the 2 computed fields I am having issues with - the correct max length value is shown grayed out "12 and 8 respectively" meaning the database returns what was original set, so the issue is likely not in the default field storage) so it has to be somewhere during rendering after the value is calculated - somehow 1 is subtracted from the fields max length before being displayed.
I'm not 100% sure but I think Drupal's default handling of any fields input exceeding max length of allowed characters would normally returns an error stating the fact. Being that isn't happening here tells me the computed fields validation passed (during node add/edit save) and has to do with some calculation during display rendering maybe in the field formatter. Unless for some reason computed fields don't adhere to standard field validation, which if that is the case there could be a bigger issue.
With all that, I'm not sure where to start looking to create a patch for this issue.
For now as a work around (should someone else fall victim to this issue) just replace the computed fields with new ones making the max length +1 more than actually needed (so if you need 12, make it 13 - if you need 8, make it 9..and so on).
This should be duplicatable as well based on the tests I ran should someone wish to try and solve this issue.