本文整理汇总了PHP中PFBC\Form::clearValues方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::clearValues方法的具体用法?PHP Form::clearValues怎么用?PHP Form::clearValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PFBC\Form
的用法示例。
在下文中一共展示了Form::clearValues方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: findUser
exit;
}
// Namespaces to use
use PFBC\Form;
use PFBC\Element;
use PFBC\Validation;
// If form is submitted and correct
if (!empty($_POST) && Form::isValid("assignExaminator", false)) {
$uid = findUser($_POST['username']);
// Get current Course
$course = $user->getCourse($cid);
if ($uid == -1) {
Form::setError('assignExaminator', 'Error: Unable to find that user.');
header("Location: ?view=assignexaminator&cid={$cid}");
exit;
} else {
Form::clearValues('assignExaminator');
}
// Add user to examinators
$course->addExaminator($uid);
echo '<h3>Success!</h3><a href="?view=course&cid=' . $cid . '"><button class="btn btn-success">Go back</button></a>';
} else {
$form = new Form("assignExaminator");
$form->configure(array("action" => "?view=assignexaminator&cid={$cid}"));
$form->addElement(new Element\HTML('<legend>Assign new examinator</legend>'));
$form->addElement(new Element\Hidden("form", "assignExaminator"));
$form->addElement(new Element\Textbox('Username:', 'username', array('validation' => new Validation\RegExp('/^[a-z\\d]{2,64}$/', 'Error: The %element% field must contain a username.'), 'required' => 1, 'longDesc' => 'This user will be added as an examinator to the course')));
$form->addElement(new Element\Button("Add user"));
$form->addElement(new Element\Button("Cancel", "button", array("onclick" => "history.go(-1);")));
$form->render();
}
示例2: getCID
}
// Get course id
$cid = getCID();
// Namespaces to use
use PFBC\Form;
use PFBC\Element;
use PFBC\Validation;
// If form is submitted and correct
if (!empty($_POST) && Form::isValid("assignCourseAdmin", false)) {
$uid = findUser($_POST['username']);
// Get current Course
$course = $user->getCourse($cid);
if ($uid == -1) {
Form::setError('assignCourseAdmin', 'Error: Unable to find that user.');
header("Location: ?view=assigncourseadmin&cid={$cid}");
} else {
Form::clearValues('assignCourseAdmin');
}
// Add user to admins
$course->addAdmin($uid);
echo '<h3>Success!</h3><a href="?view=course&cid=' . $cid . '"><button class="btn btn-success">Go back</button></a>';
} else {
$form = new Form("assignCourseAdmin");
$form->configure(array("action" => "?view=assigncourseadmin&cid={$cid}"));
$form->addElement(new Element\HTML('<legend>Assign new course administrator</legend>'));
$form->addElement(new Element\Hidden("form", "assignCourseAdmin"));
$form->addElement(new Element\Textbox('Username:', 'username', array('validation' => new Validation\RegExp('/^[a-z\\d]{2,64}$/', 'Error: The %element% field must contain a username.'), 'required' => 1, 'longDesc' => 'This user will be added as a course admin to the course')));
$form->addElement(new Element\Button("Add user"));
$form->addElement(new Element\Button("Cancel", "button", array("onclick" => "history.go(-1);")));
$form->render();
}
示例3: findUser
// If form is submitted and correct
if (!empty($_POST) && Form::isValid("addUser", false)) {
$uid = findUser($_POST['username']);
// Get current Course
$course = $user->getCourse($cid);
if ($uid == -1) {
Form::setError('addUser', 'Error: Unable to find that user.');
header("Location: ?view=addusertocourse&cid={$cid}");
exit;
} else {
if ($course->userIsAssigned($uid)) {
Form::setError('addUser', 'Error: That user is already assigned to this course.');
header("Location: ?view=addusertocourse&cid={$cid}");
exit;
} else {
Form::clearValues('addUser');
}
}
// Add course to user
$newUser = new User($uid);
$newUser->addCourse($course->id);
// Add user to course
$course->addUser($uid);
echo '<h3>Success!</h3><a href="?view=course&cid=' . $cid . '"><button class="btn btn-success">Go back</button></a>';
} else {
$form = new Form("addUser");
$form->configure(array("action" => "?view=addusertocourse&cid={$cid}"));
$form->addElement(new Element\HTML('<legend>Add user to course</legend>'));
$form->addElement(new Element\Hidden("form", "addUser"));
$form->addElement(new Element\Textbox('Username:', 'username', array('validation' => new Validation\RegExp('/^[a-z\\d]{2,64}$/', 'Error: The %element% field must contain a username.'), 'required' => 1, 'longDesc' => 'This user will be added to the course')));
$form->addElement(new Element\Button("Add user"));
示例4: findUser
exit;
}
// Namespaces to use
use PFBC\Form;
use PFBC\Element;
use PFBC\Validation;
// If form is submitted and correct
if (!empty($_POST) && Form::isValid("assignReviewer", false)) {
$uid = findUser($_POST['username']);
// Get current Course
$course = $user->getCourse($cid);
if ($uid == -1) {
Form::setError('assignReviewer', 'Error: Unable to find that user.');
header("Location: ?view=assignreviewer&cid={$cid}");
exit;
} else {
Form::clearValues('assignReviewer');
}
// Add user to examinators
$course->addReviewer($uid);
echo '<h3>Success!</h3><a href="?view=course&cid=' . $cid . '"><button class="btn btn-success">Go back</button></a>';
} else {
$form = new Form("assignReviewer");
$form->configure(array("action" => "?view=assignreviewer&cid={$cid}"));
$form->addElement(new Element\HTML('<legend>Assign new reviewer</legend>'));
$form->addElement(new Element\Hidden("form", "assignReviewer"));
$form->addElement(new Element\Textbox('Username:', 'username', array('validation' => new Validation\RegExp('/^[a-z\\d]{2,64}$/', 'Error: The %element% field must contain a username.'), 'required' => 1, 'longDesc' => 'This user will be added as a reviewer to the course')));
$form->addElement(new Element\Button("Add user"));
$form->addElement(new Element\Button("Cancel", "button", array("onclick" => "history.go(-1);")));
$form->render();
}