Skip to content
Snippets Groups Projects
Commit 7b853b45 authored by Peter Rotich's avatar Peter Rotich
Browse files

Merge pull request #293 from greezybacon/issue/276


forms: Require `title` for all custom forms

Reviewed-By: default avatarPeter Rotich <peter@osticket.com>
parents 1767c112 a3b13445
No related branches found
No related tags found
No related merge requests found
......@@ -216,9 +216,11 @@ class Bootstrap {
define('LATIN1_UC_CHARS', 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝ');
define('LATIN1_LC_CHARS', 'àáâãäåæçèéêëìíîïðñòóôõöøùúûüý');
function mb_strtoupper($str) {
if (is_array($str)) $str = $str[0];
return strtoupper(strtr($str, LATIN1_LC_CHARS, LATIN1_UC_CHARS));
}
function mb_strtolower($str) {
if (is_array($str)) $str = $str[0];
return strtolower(strtr($str, LATIN1_UC_CHARS, LATIN1_LC_CHARS));
}
define('MB_CASE_LOWER', 1);
......
......@@ -37,6 +37,8 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info);
<td><input type="text" name="title" size="40" value="<?php
echo $info['title']; ?>"/>
<i class="help-tip icon-question-sign" href="#form_title"></i>
<font class="error"><?php
if ($errors['title']) echo '<br/>'; echo $errors['title']; ?></font>
</td>
</tr>
<tr>
......
......@@ -8,12 +8,15 @@ if($_REQUEST['id'] && !($form=DynamicForm::lookup($_REQUEST['id'])))
if($_POST) {
$fields = array('title', 'notes', 'instructions');
$required = array('subject');
$required = array('title');
$max_sort = 0;
switch(strtolower($_POST['do'])) {
case 'update':
foreach ($fields as $f)
if (isset($_POST[$f]))
if (in_array($f, $required) && !$_POST[$f])
$errors[$f] = sprintf('%s is required',
mb_convert_case($f, MB_CASE_TITLE));
elseif (isset($_POST[$f]))
$form->set($f, $_POST[$f]);
$form->save(true);
$names = array();
......@@ -107,6 +110,8 @@ if($_POST) {
}
if ($errors)
$errors['err'] = 'Unable to commit form. Check validation errors';
else
$msg = 'Custom form successfully updated';
}
$page='dynamic-forms.inc.php';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment