From 70eb622aa9155f103b1e448c2e88040cd1898d29 Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Fri, 26 Sep 2014 13:30:48 -0500
Subject: [PATCH] forms: Add free text field

This is similar to the section break but doesn't have the <hr> element
before it and allows for HTML input (including images)
---
 include/class.forms.php | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/include/class.forms.php b/include/class.forms.php
index 8892b2592..1c1f70178 100644
--- a/include/class.forms.php
+++ b/include/class.forms.php
@@ -179,6 +179,7 @@ class FormField {
             'choices' => array( /* @trans */ 'Choices', 'ChoiceField'),
             'files' => array(   /* @trans */ 'File Upload', 'FileUploadField'),
             'break' => array(   /* @trans */ 'Section Break', 'SectionBreakField'),
+            'free' => array(    /* @trans */ 'Free Text', 'FreeTextField'),
         ),
     );
     static $more_types = array();
@@ -2125,6 +2126,42 @@ class FileUploadWidget extends Widget {
 
 class FileUploadError extends Exception {}
 
+class FreeTextField extends FormField {
+    static $widget = 'FreeTextWidget';
+
+    function getConfigurationOptions() {
+        return array(
+            'content' => new TextareaField(array(
+                'configuration' => array('html' => true),
+                'label'=>__('Content'), 'required'=>true, 'default'=>'',
+                'hint'=>__('Free text shown in the form, such as a disclaimer'),
+            )),
+        );
+    }
+
+    function hasData() {
+        return false;
+    }
+
+    function isBlockLevel() {
+        return true;
+    }
+}
+
+class FreeTextWidget extends Widget {
+    function render($mode=false) {
+        $config = $this->field->getConfiguration();
+        ?><div class=""><h3><?php
+            echo Format::htmlchars($this->field->get('label'));
+        ?></h3><em><?php
+            echo Format::htmlchars($this->field->get('hint'));
+        ?></em><div><?php
+            echo Format::viewableImages($config['content']); ?></div>
+        </div>
+        <?php
+    }
+}
+
 class VisibilityConstraint {
 
     const HIDDEN =      0x0001;
-- 
GitLab