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;
?>
Deleting the field will hide it from the user interface; it will
not remove it from the database.
If you add the field back later on, the data previously entered
will be visible again.
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 "$name | $type | $label |
\n";
}
echo "
\n";
}
?>