We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 45012
    • 3 Posts
    Hi!
    I'm working on addon for MODX Revo. My component is CRC based on modResource. I have problem with save in admin panel. If content field contains any html tag, saving progress is looped, answer is
    {"success":true,"message":"startups_ok","total":0,"data":[],"object":{"id":587,"type":"document","contentType"
    :"text\/html","pagetitle":"\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430","longtitle":"","description"
    :"","alias":"","link_attributes":"","published":false,"pub_date":0,"unpub_date":0,"parent":186,"isfolder"
    :false,"introtext":"","content":"<p>\u0442\u0435\u043a\u0441\u0442<\/p>","richtext":true,"template":5
    ,"menuindex":0,"searchable":true,"cacheable":true,"createdby":3,"createdon":"2015-05-16 14:21:49","editedby"
    :0,"editedon":0,"deleted":false,"deletedon":0,"deletedby":0,"publishedon":0,"publishedby":0,"menutitle"
    :"","donthit":false,"privateweb":false,"privatemgr":false,"content_dispo":0,"hidemenu":true,"class_key"
    :"Startup","context_key":"web","content_type":1,"uri":"projects\/design\/flat\/\u043f\u0440\u043e\u0432
    \u0435\u0440\u043a\u0430.html","uri_override":0,"hide_children_in_tree":0,"show_in_tree":1,"properties"
    :null,"create-resource-token":"557b399566f044.71730680","reloaded":"0","parent-original":"186","parent-cmb"
    :"Flat (186)","syncsite":"0","ta":"<p>\u0442\u0435\u043a\u0441\u0442<\/p>","action":"resource\/update"
    ,"resource_groups":"[]"}}
    

    If content field have not tags, all saved correctly.
    ModResuorce saved correctly anyway.
    can someone help me&
      • 51194
      • 1 Posts
      derek_melton Reply #2, 11 years ago
      I think you should check the code of the method cleanup() of the file core/model/modx/processors/resource/update.class.php
      Probably you've overwritten the method and now you're not properly clearing "$this->object" object

      Extjs throws error because of the way it process a request - if any tags are present in a request from the server after pushing the "save" button it brakes. You can see the logic in ext-all-debug.js at ~4748 line (extjs 3.4.1.1):

      if(doc){
      	if(doc.body){
      		if(/textarea/i.test((firstChild = doc.body.firstChild || {}).tagName)){
      			r.responseText = firstChild.value;
      		}else{
      			r.responseText = doc.body.innerHTML;
      		}
      	}
      
      	r.responseXML = doc.XMLDocument || doc;
      }
      


      The call
      firstChild = doc.body.firstChild

      is not working properly

      Your goal is not to send any html tags in response from the server. Good luck