-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpost.php
55 lines (47 loc) · 1.35 KB
/
post.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
<?php
require('vendor/autoload.php');
require('model.php');
use Formularium\FrameworkComposer;
use Formularium\Model;
// set your framework composition
$framework = FrameworkComposer::create(['HTML', 'Bootstrap']);
// build the model
$model = modelData();
// validate some data
$validation = $model->validate($_POST);
?><!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<title>Formularium pure PHP</title>
<?php echo $framework->htmlHead(); ?>
</head>
<body>
<div class='container'>
<h1>Formularium pure PHP</h1>
<p>
This is a simple example of using <a href="https://github.com/Corollarium/Formularium">Formularium</a> in a framework agnostic way.
</p>
<div>
<?php
if (!empty($validation['errors'])) {
foreach ($validation['errors'] as $fieldName => $error) {
echo "<p class='alert alert-danger'>$fieldName has an error: $error</p>";
}
}
else {
// get data after validation
$validated = $validation['validated'];
// render a view
echo $model->viewable($framework, $validated);
}
?>
</div>
<footer style="text-align: center; margin-top: 2em;">
<small>
See <a href="https://github.com/Corollarium/Formularium">Formularium on GitHub</a>
</small>
<?php echo $framework->htmlFooter(); ?>
</footer>
</div>
</html>