From 93c390c3150024ca860fb1a35f0737b4da419eca Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Wed, 4 Jun 2014 11:44:09 -0500 Subject: [PATCH] forms: Ensure the issue summary will have data Otherwise, no column will be added to the %ticket__cdata table and the ticket queue pages will be crashed (empty). --- include/class.dynamic_forms.php | 5 ++++- include/staff/dynamic-form.inc.php | 6 +++++- scp/forms.php | 7 +++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/include/class.dynamic_forms.php b/include/class.dynamic_forms.php index b49cca3a1..206db1ef9 100644 --- a/include/class.dynamic_forms.php +++ b/include/class.dynamic_forms.php @@ -330,7 +330,10 @@ class DynamicFormField extends VerySimpleModel { array($this->getField(), $what), $args); } - function getField() { + function getField($cache=true) { + if (!$cache) + return new FormField($this->ht); + if (!isset($this->_field)) $this->_field = new FormField($this->ht); return $this->_field; diff --git a/include/staff/dynamic-form.inc.php b/include/staff/dynamic-form.inc.php index b1d121e4c..bf26fa1ef 100644 --- a/include/staff/dynamic-form.inc.php +++ b/include/staff/dynamic-form.inc.php @@ -154,7 +154,11 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); $('#field-config').show(); return false; "><i class="icon-edit"></i> Config</a> - <?php } ?></td> + <?php } ?> + <div class="error" style="white-space:normal"><?php + if ($ferrors['type']) echo $ferrors['type']; + ?></div> + </td> <td><input type="checkbox" name="private-<?php echo $id; ?>" <?php if ($f->get('private')) echo 'checked="checked"'; ?> <?php echo $force_privacy ?>/></td> diff --git a/scp/forms.php b/scp/forms.php index d739a9904..567054c60 100644 --- a/scp/forms.php +++ b/scp/forms.php @@ -46,6 +46,13 @@ if($_POST) { $field->addError('Field variable name is not unique', 'name'); if (preg_match('/[.{}\'"`; ]/u', $field->get('name'))) $field->addError('Invalid character in variable name. Please use letters and numbers only.', 'name'); + // Subject (Issue Summary) must always have data + if ($form->get('type') == 'T' && $field->get('name') == 'subject') { + if (($f = $field->getField(false)->getImpl()) && !$f->hasData()) + $field->addError('The issue summary must be a field ' + .'that supports user input, such as short answer', + 'type'); + } if ($field->get('name')) $names[] = $field->get('name'); if ($field->isValid()) -- GitLab