We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8425
    • 159 Posts
    Hello,
    I’m using at TV [*articleContent*] of type RichText for the main content for the NewsPublisher snippet. When I submit a blog, the richtext control always clear. It doesn’t happen if I use a regular textarea control.
    How can I retain a richtext control content upon submission? I need it when the form redisplay upon a validation error.
    Thanks
      • 16278
      • 928 Posts
      The template variable does not get its value restored via placeholders along with other fields in the foreach loop near the end of the snippet. I found a way around this recently, while writing my own version of NewsPublisher. What follows has been tested on a standard MODx install with the sample content, i.e. a chunk called FormBlog that has a TV called blogContent for the main text area.

      1) in the TV, add a placeholder such as [+richContent+] as the Default Value
      2) about 6 lines from the end of the NewsPublisher snippet, add a line to set the placeholder to the rich content string that was returned within the $_POST variables
       ...
             } else {
                  foreach($_POST as $n=>$v) {
                      $formTpl = str_replace('[+'.$n.'+]',$v,$formTpl);
                  }
                  $modx->setPlaceholder('richContent',$_POST[$rtcontent]);
              }
      ...


      My snippet call looks like this:
      [!NewsPublisher? &formtpl=`FormBlog` &rtcontent=`tvblogContent`!]


      cool
      KP
        • 8416
        • 173 Posts
        Perfect you made my day. It works like a charm smiley