We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 34084 ☆ A M B ☆
    • 756 Posts
    Have CMP when submitting any htmleditor xtype content I get back a valid JSON object response:

    {"success":true,"message":"","total":0,"data":[],"object":{"id":4,"name":"JB","fulladdress":"123 West Elm","description":"<strong style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; outline-width: initial; outline-style: none; outline-color: initial; font-size: 12px; vertical-align: baseline; color: rgb(51, 51, 51); font-family: Arial, Helvetica, sans-serif; line-height: 17px; background-color: rgb(242, 242, 229); \">   *** MICHAEL WINSLOW ***<\/strong><strong style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; outline-width: 0px; outline-style: initial; outline-color: initial; font-size: 12px; vertical-align: baseline; color: rgb(51, 51, 51); font-family: Arial, Helvetica, sans-serif; line-height: 17px; background-color: rgb(242, 242, 229); \">  <\/strong>","review":"","hours":"","categoryid":1,"sectionid":2,"image":{"name":"","type":"","tmp_name":"","error":4,"size":0},"ispremium":true,"active":true,"isadult":false,"createdon":null,"createdby":0,"editedon":null,"editedby":0,"action":"mgr\/business\/update","HTTP_MODAUTH":"modx4ffa6690ec2db8.70432621_14ffbb1a398aed5.35086175","file":{"name":"","type":"","tmp_name":"","error":4,"size":0}}}


    And the ext-all.js is throwing an "Uncaught SyntaxError: Unexpected token ILLEGAL" JS error, which is causing the issue with the dialog for saving not closing properly. The actual content however is being stored properly in the database as if I do a page refresh all the HTML content submitted is saved and properly formatted.

    Anyone else dealing with this as well.

    Modx 2.2.4-pl (traditional)
    PHP 5.3
      Evo Revo // Ubuntu, CentOS, Win // Apache 2x, Lighttp (Lighty)
      Visit CharlesMx.com for latest news and status updates.
      • 33968
      • 863 Posts
      Could you post the relevant CMP code, there might be a problem with your success handler.
        • 34084 ☆ A M B ☆
        • 756 Posts
        It uses the modObjectUpdateProcessor abstract class:

        <?php
        class BusinessUpdateProcessor extends modObjectUpdateProcessor {
            public $classKey = 'Business';
            public $languageTopics = array('mxservicelistings:default');
            public $objectType = 'mxservicelistings';
            
            public function beforeSave() {
                global $modx;
                
                //-- Force the checkbox property value
                $this->setCheckbox('ispremium',true);
                $this->setCheckbox('isadult',true);
                $this->setCheckbox('active', true);
                
                
                $this->setProperty('editedon', time());
                $this->setProperty('editedby', $modx->getLoginUserID() );
                
                return parent::beforeSave();
            }
        }
        return 'BusinessUpdateProcessor';
          Evo Revo // Ubuntu, CentOS, Win // Apache 2x, Lighttp (Lighty)
          Visit CharlesMx.com for latest news and status updates.
          • 33968
          • 863 Posts
          Sorry I meant your JS code. However I wonder if something in the html/css in your 'description' field is causing the syntax error. Can you temporarily override it by setting it to an empty string and see if that works without errors?
            • 34084 ☆ A M B ☆
            • 756 Posts
            Yes, it will work without errors if set to empty. My current solution is to just scrub the data on the abstract function cleanup(){} to remove all html entities (strip_tags()) and that seems to work though it still doesn't seem right.
              Evo Revo // Ubuntu, CentOS, Win // Apache 2x, Lighttp (Lighty)
              Visit CharlesMx.com for latest news and status updates.
              • 39519 ☆ A M B ☆
              • 79 Posts
              BUMP* I'm having this exact same problem trying to incorporate a Rich Text field into my CMP. Has anyone ever found a better solution?
                Mat Dave Jones
                • 34084 ☆ A M B ☆
                • 756 Posts
                This is usually caused when the response JSON object is not properly escaped/encoded; thus breaking the JSON format. View your Network response in your console and see what the response from your action looks like. Then you can isolate the object to modify the class object to return the properly encoded response. Hope that gets you going in the right track, let me know if you need more information or more detailed example.

                Cheers
                  Evo Revo // Ubuntu, CentOS, Win // Apache 2x, Lighttp (Lighty)
                  Visit CharlesMx.com for latest news and status updates.
                  • 3749
                  • 24,544 Posts
                  Another possibility is an E_NOTICE error in the PHP which gets returned instead of the JS code, as described here: http://bobsguides.com/blog.html/2013/05/22/debugging-cmps-a-horror-story/
                    Did I help you? Buy me a beer
                    Get my Book: MODX:The Official Guide
                    MODX info for everyone: http://bobsguides.com/modx.html
                    My MODX Extras
                    Bob's Guides is now hosted at A2 MODX Hosting
                    • 39519 ☆ A M B ☆
                    • 79 Posts
                    ya, basically had to do something similar to what CharlesMX did, but I altered in in the aftersave. For future reference I'll detail my resulting fix here. Since I wasn't doing anything with the response, I just converted the troubled object to a boolean in the response.

                    On the actual php class that I used to extend the modObjectUpdateProcessor I altered the afterSave function like so:

                        public function afterSave() {
                            $this->object->set('description', true);
                            return true;
                        }
                    
                      Mat Dave Jones