-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcategory_edit.php
59 lines (44 loc) · 1.42 KB
/
category_edit.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
include_once("includes/inc.global.php");
$p->site_section = LISTINGS;
$p->page_title = _("Edit Listing Category");
include("includes/inc.forms.php");
include_once("classes/class.category.php");
//
// Define form elements
//
$cUser->MustBeLevel(2);
$category = new cCategory();
$category->LoadCategory($_REQUEST["category_id"]);
$form->addElement("hidden", "category_id", $_REQUEST["category_id"]);
$form->addElement("text", "category", _("Category Description"), array("size" => 30, "maxlength" => 30));
$form->addElement("static", null, null, null);
$form->addElement('submit', 'btnSubmit', _("Submit"));
//
// Define form rules
//
$form->addRule('category', _("Category description cannot be blank"), 'required');
//
// Then check if we are processing a submission or just displaying the form
//
if ($form->validate()) { // Form is validated so processes the data
$form->freeze();
$form->process("process_data", false);
} else {
$form->setDefaults(array("category"=>$category->description));
$p->DisplayPage($form->toHtml()); // just display the form
}
function process_data ($values) {
global $p, $cErr, $category;
$category->description = $values["category"];
if ($category->SaveCategory()) {
$output = _("The category has been updated.");
} else {
$output = _("Could not save changes to the category.")." "._("Please try again later.");
}
$p->DisplayPage($output);
}
//
// Form rule validation functions
//
?>