field_types[$type])) { throw new Exception("invalid type $type"); } $name = MTrackTicket_CustomField::canonName($name); if (!preg_match("/^x_[a-z_]+$/", $name)) { throw new Exception("invalid field name $name"); } $field = $C->fieldByName($name, true); if (isset($_POST['delete'])) { $C->deleteField($field); } else { $field->group = $group; $field->label = $label; $field->type = $type; $field->order = $order; $field->options = $options; $field->default = $default; } $C->save(); MTrackConfig::save(); header("Location: ${ABSWEB}admin/customfield.php"); exit; } mtrack_head("Administration - Custom Fields"); echo "

Custom Fields

"; $field = null; if (isset($_GET['add'])) { $field = new MTrackTicket_CustomField; $field->type = 'text'; $field->name = 'x_fieldname'; $field->label = 'The Label'; $field->group = 'Custom Fields'; } else if (isset($_GET['field'])) { $field = $C->fieldByName($_GET['field']); if ($field === null) { throw new Exception("No such field " . $_GET['field']); } } if ($field) { $type = mtrack_select_box('type', $C->field_types, $field->type); $name = htmlentities($field->name, ENT_QUOTES, 'utf-8'); $label = htmlentities($field->label, ENT_QUOTES, 'utf-8'); $group = htmlentities($field->group, ENT_QUOTES, 'utf-8'); $options = htmlentities($field->options, ENT_QUOTES, 'utf-8'); $default = htmlentities($field->default, ENT_QUOTES, 'utf-8'); $order = $field->order; ?>
Edit Custom Field

The field name to use in the database. Must have a prefix of 'x_' and must only contain characters a-z or underscore. You cannot rename a field; once it is created, it stays in the database. You can use the label field below if you want to change the presentation.

The label to display on the ticket screen

Fields with the same group are grouped together on the ticket editing screen

Enter the default value for this field

For Select and Multi-Select types, enter a list of possible choices here, separated by a pipe character |

Lower means show first. If two or more fields have same 'order', then they are ordered by name
getGroupedFields(); foreach ($grouped as $groupname => $group) { $groupname = htmlentities($groupname, ENT_QUOTES, 'utf-8'); echo "Group: $groupname
\n\n"; foreach ($group as $field) { $type = $field->type; $label = htmlentities($field->label, ENT_QUOTES, 'utf-8'); $name = $field->name; $name = "$name"; echo "\n"; } echo "
$name$type$label
\n"; } ?>