Announcement

Collapse
No announcement yet.

Magento2, custom widget save data wrong encoding

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Magento2, custom widget save data wrong encoding

    I create a custom widget for magento2. I have one text parameter:
    Code:
      
     <parameter name="title" xsi:type="text"  visible="true" sort_order="1" >    <label translate="true">Title</label> </parameter>
    When I save data, if I use characters like à, or ã, or ü por example, the are saved with wrong encoding. For example ü became ü. This only happens on my widget. All the rest is saving with right encoding.
    How can I set right encoding for a widget or a parameter?
    thank you



  • #2
    Hi! As the recommendation, try to check your own file encoding. I had the same problem with Magento 1.

    Comment


    • #3
      Hello Kevin,

      Thank you for your anwser, but my files are all in UTF-8.

      Comment


      • #4
        Ok, try to test and display information to your page to see what the text is. With Zend_Debug :: dump (), for example.

        If unreadable symbols are appearing, you need to use a different encoding for text, for example:

        Code:
        $ Variable = 'some text';
        $ Variable = mb_convert_encoding ($ variable, 'UTF-8', mb_detect_encoding ($ variable));
        echo htmlspecialchars ($ variable, ENT_QUOTES, 'UTF-8');

        Comment


        • #5
          Throught his tutorial, you can easily fix Magento 2 widget creation issue. https://www.cloudways.com/blog/magento-2-custom-widget/

          Comment

          Working...
          X