We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19328
    • 433 Posts
    I'm creating resources when a user submits a form. This works well, but I just discovered that there's a problem with quotation marks.
    When a user enters a text with a quotation mark (") in the textarea, everything after the quotation mark is not saved.

    I'm using this code to put the content of the textarea in the content of the resource:
    $resource->setContent($hook->getValue('comment'));


    Does anyone know where I should be escaping or filtering (?) the quotation marks?

    Thanks for any help

      • 7923
      • 4,213 Posts
      Have you got your question resolved?

      You can debug your code by echoing the content of your variables and calling die function to see the echo.

      for example use this to see what's the comment field returns and if it has content already missing or not:

      echo $hook->getValue('comment');die();


      If your content is missing after first quotation mark in the echo, then the hook is not getting the value properly from the form and you must look closer at Formit and how it parses your content before sending it to your hook.

      If the content is ok in the echo, you can try adding slashes to it when setting it to the resource.

      $resource->setContent(addslashes($hook->getValue('comment')));


        "He can have a lollipop any time he wants to. That's what it means to be a programmer."