We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22574
    • 181 Posts
    Hey all,

    Just wondering if anyone has worked out how to make a custom database field rich text editable within a module?

    I have modified TreasureChest to include some new fields, they save and pull out from the database I just need to make them rich text so that the client can add paragraphs, bold etc...

    Also how do I limit the allowed characters in a field?

    Thanks
      • 4310
      • 2,310 Posts
      This is lifted from the easynewsletter module :
      // Get access to template variable function (to output the RTE)
      			include_once($modx->config['base_path'].'manager/includes/tmplvars.inc.php');
      		  
      			$event_output = $modx->invokeEvent("OnRichTextEditorInit", array('editor'=>$modx->config['which_editor'], 'elements'=>array('tvmailMessage')));
      		
      			if(is_array($event_output)) {
      				$editor_html = implode("",$event_output);
      			}
      			
      			// Get HTML for the textarea, last parameters are default_value, elements, value
      			$rte_html = renderFormElement('richtext', 'mailMessage', '', '', $newsletter);
      			
      			echo $rte_html;
      			
      			echo $editor_html;
        • 22574
        • 181 Posts
        Thanks Bunk I used that info as a guide and built a custom bit of code, cheers!
          • 4310
          • 2,310 Posts
          No problem smiley