You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Environment includes use of text field options for products with max character limits.
Steps to reproduce (*)
Go to a product page with a textfield option that has a defined maximum character limit.
Enter text into the textfield that includes line breaks ("\n") positioned within the text, not at the beginning or end. Ensure the total number of characters, counting each line break as a single character, exactly matches the character limit.
Submit the form to add the product to the cart.
Expected result (*)
The text should be validated correctly by JavaScript as the number of characters (counting line breaks as single characters) matches the limit, allowing the product to be added to the cart without any errors.
Actual result (*)
JavaScript validation passes and the form submits, but Magento returns an error stating "text is too long". This occurs because line breaks are counted as two characters ("\r\n") in backend validation, exceeding the character limit.
Proposed Solution
Adjust the counting mechanism in app/code/local/Mage/Catalog/Model/Product/Option/Type/Text.php to handle line breaks correctly by accounting for carriage returns ("\r") and adjusting the character count accordingly, ensuring the trim() function’s effect is considered in the character validation process.
Consider whether there is a more suitable place or method to normalize text input before validation. Could normalization be applied earlier in the data handling process to prevent such errors and ensure data consistency across different system layers?
The text was updated successfully, but these errors were encountered:
Preconditions (*)
Steps to reproduce (*)
Expected result (*)
Actual result (*)
Proposed Solution
app/code/local/Mage/Catalog/Model/Product/Option/Type/Text.php
to handle line breaks correctly by accounting for carriage returns ("\r") and adjusting the character count accordingly, ensuring thetrim()
function’s effect is considered in the character validation process.The text was updated successfully, but these errors were encountered: