本文整理汇总了PHP中PFBC\Form::configure方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::configure方法的具体用法?PHP Form::configure怎么用?PHP Form::configure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PFBC\Form
的用法示例。
在下文中一共展示了Form::configure方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: array
)));
$form->addElement(new Element_Button("Login"));
$form->addElement(new Element_Button("Cancel", "button", array(
"onclick" => "history.go(-1);"
)));
$form->render();');
?>
</div>
</div>
<?php
use PFBC\Form;
use PFBC\Element;
$form = new Form("login");
$form->configure(array("prevent" => array("bootstrap", "jQuery", "focus")));
$form->addElement(new Element\HTML('<legend>Login</legend>'));
$form->addElement(new Element\Hidden("form", "login"));
$form->addElement(new Element\Email("Email Address:", "Email", array("required" => 1)));
$form->addElement(new Element\Password("Password:", "Password", array("required" => 1)));
$form->addElement(new Element\Checkbox("", "Remember", array("1" => "Remember me")));
$form->addElement(new Element\Button("Login"));
$form->addElement(new Element\Button("Cancel", "button", array("onclick" => "history.go(-1);")));
$form->render();
?>
<p><strong>Line 2:</strong> PFBC uses PHP sessions in the validation process, so you'll need to ensure you have session_start(); in your
webpage - before outputting anything to the browser. If you forget, you'll be reminded by an error message displayed above your form.</p>
<p><strong>Lines 4-5:</strong> As previously mentioned, PFBC <?php
echo $version;
示例3: foreach
use PFBC\Form;
use PFBC\Element;
use PFBC\Validation;
// If form is submitted and correct
if (!empty($_POST) && Form::isValid("selectProjectsToReview")) {
// Add reviewer to all selected projects
foreach ($_POST['projects'] as $key => $value) {
try {
$project = $course->getProject($value);
$project->addFeasibleReviewer($GLOBALS['user']->id);
} catch (Exception $e) {
// Do nothing, quietly continue
}
}
echo '<h3>Success!</h3><a href="?view=course&cid=' . $cid . '"><button class="btn btn-success">Go back</button></a>';
} else {
// Add all projects
$projects = array();
foreach ($course->getProject(null, false) as $key => $value) {
$project = $course->getProject($value);
$projects[$value] = $project->subject;
}
$form = new Form("selectProjectsToReview");
$form->configure(array("action" => "?view=selectprojects&cid={$cid}"));
$form->addElement(new Element\HTML('<legend>Select projects</legend>'));
$form->addElement(new Element\Hidden("form", "selectProjectsToReview"));
$form->addElement(new Element\Checkbox("Projects I can review:", "projects", $projects));
$form->addElement(new Element\Button("Send"));
$form->addElement(new Element\Button("Cancel", "button", array("onclick" => "history.go(-1);")));
$form->render();
}
示例4: header
// 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"));
$form->addElement(new Element\Button("Cancel", "button", array("onclick" => "history.go(-1);")));
$form->render();
}
示例5: DateTime
}*/
$subject = $_POST['subject'];
$deadline = new DateTime($_POST['deadline'] . ' ' . $_POST['deadlineTime']);
$stage = intval($_POST['stage']);
// Create Project
$project = Project::createProject($subject, $deadline, $stage, $cid);
// Add the project to the course
$course->addProject($project->id);
// Add the student to the project
//$project->addStudent($uid);
// Add a submission to the Project
$project->createSubmission();
echo '<h3>Success!</h3><a href="?view=course&cid=' . $cid . '"><button class="btn btn-success">Go back</button></a>';
} else {
$form = new Form('createProject');
$form->configure(array('action' => "?view=createproject&cid={$cid}"));
$form->addElement(new Element\HTML('<legend>Create new project</legend>'));
$form->addElement(new Element\Hidden('form', 'createProject'));
$form->addElement(new Element\Textbox('Subject:', 'subject', array('validation' => new Validation\RegExp('/^[\\p{L} ]{2,64}$/', 'Error: The %element% field must contain only characters and whitespaces and be between 2 and 64 characters.'), 'required' => 1)));
$form->addElement(new Element\Select('Stage:', 'stage', $stages, array('validation' => new Validation\RegExp('/^[1-5]{1}$/', 'Error: The %element% field is not valid.'), 'required' => 1, 'longDesc' => 'Starting stage of the project')));
/* $form->addElement(new Element\Textbox('Student:', 'student', array(
//TODO The regex should use defined constants to more easily adapt
//TODO a better regex should be implemented depending on acronym
'validation' => new Validation\RegExp('/^[a-z\d]{2,64}$/', 'Error: The %element% field must contain a username.'),
'required' => 1,
'longDesc' => 'Assign a student to this project with it\'s acronym'
)));*/
$form->addElement(new Element\Date('Deadline:', 'deadline', array('required' => 1, 'longDesc' => 'Select a deadline for this project')));
$form->addElement(new Element\Time('Time:', 'deadlineTime', array('required' => 1, 'longDesc' => 'Select a time for the deadline')));
$form->addElement(new Element\Button('Create'));
$form->addElement(new Element\Button('Cancel', 'button', array('onclick' => 'history.go(-1);')));
示例6: 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();
}
示例7: Form
<div class="page-header">
<h1>Ajax</h1>
</div>
<p>PFBC provides several properties and methods for facilitating ajax submissions. To get started, you'll first need to set the ajax property in
the form's configure method. The ajaxCallback property can also be included in the configure method if you'd like a javascript function to called
after the form's data has been submitted. In the example below a callback function has been set to extract the latitude/longitude information from a
json response.</p>
<p>The validation process for an ajax submission also differs slightly from that of a standard submission. If the form's isValid method
returns false, you will need to invoke the renderAjaxErrorResponse method, which returns a json response containing the appropriate error messages.
These errors will then be displayed in the form so the user can correct and resubmit.</p>
<?php
$form = new Form("ajax");
$form->configure(array("prevent" => array("bootstrap", "jQuery"), "ajax" => 1, "ajaxCallback" => "parseJSONResponse"));
$form->addElement(new Element\Hidden("form", "ajax"));
$form->addElement(new Element\HTML('<legend>Using the Google Geocoding API</legend>'));
$form->addElement(new Element\Textbox("Address:", "Address", array("required" => 1)));
$form->addElement(new Element\HTML('<div id="GoogleGeocodeAPIReaponse" style="display: none;">'));
$form->addElement(new Element\Textbox("Latitude/Longitude:", "LatitudeLongitude", array("readonly" => "")));
$form->addElement(new Element\HTML('</div>'));
$form->addElement(new Element\Button("Geocode", "submit", array("icon" => "search")));
$form->render();
?>
<script type="text/javascript">
function parseJSONResponse(latlng) {
var form = document.getElementById("ajax");
if(latlng.status == "OK") {
var result = latlng.results[0];
示例8: 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();
}
示例9: array
$form->addElement(new Element_Password("Password", "Password", array(
"required" => 1
)));
$form->addElement(new Element_Checkbox("", "Remember", array(
"1" => "Remember me"
)));
$form->addElement(new Element_Button("Login"));
$form->render();');
?>
</div>
</div>
<?php
$form = new Form("search");
$form->configure(array("prevent" => array("bootstrap", "jQuery", "focus"), "view" => new View\Search()));
$form->addElement(new Element\Hidden("form", "search"));
$form->addElement(new Element\HTML('<legend>Search</legend>'));
$form->addElement(new Element\Search("", "Search", array("placeholder" => "Search", "append" => '<button class="btn btn-primary">Go</button>')));
$form->render();
?>
<ul class="nav nav-tabs">
<li class="active"><a href="#php53-4" data-toggle="tab">PFBC <?php
echo $version;
?>
(PHP 5 >= 5.3.0)</a></li>
<li><a href="#php5-4" data-toggle="tab">PFBC <?php
echo $version;
?>
(PHP 5)</a></li>
示例10: exit
}
if ($login->isUserLoggedIn() === false) {
exit(1);
}
// Test permissions
if (!$user->hasPrivilege("canCreateCourse")) {
header("Location: ?view=accessdenied");
exit;
}
// Namespaces to use
use PFBC\Form;
use PFBC\Element;
use PFBC\Validation;
// If form is submitted and correct
if (!empty($_POST) && Form::isValid("createCourse")) {
$course = Course::createCourse($_POST['name']);
// Add the course to this user
$user->addCourse($course->id);
// Add current user as admin
$course->addAdmin($_SESSION['user_id']);
echo '<h3>Success!</h3><a href="?"><button class="btn btn-success">Go back</button></a>';
} else {
$form = new Form("createCourse");
$form->configure(array("action" => "?view=createcourse"));
$form->addElement(new Element\HTML('<legend>Create new course</legend>'));
$form->addElement(new Element\Hidden("form", "createCourse"));
$form->addElement(new Element\Textbox("Name:", "name", array("validation" => new Validation\RegExp("/^[\\d\\p{L} ]{2,64}\$/", "Error: The %element% field must contain only characters, numbers and whitespaces and be between 2 and 64 characters."), "required" => 1, "longDesc" => "Name of the course")));
$form->addElement(new Element\Button("Create"));
$form->addElement(new Element\Button("Cancel", "button", array("onclick" => "history.go(-1);")));
$form->render();
}