Skip to content

Commit 76e3b85

Browse files
committed
Put page title into template, create form_validation demo
1 parent 4507d9b commit 76e3b85

File tree

7 files changed

+93
-7
lines changed

7 files changed

+93
-7
lines changed

application/packages/user_manager/controllers/users.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function m_list()
1212
{
1313
$data['user_count'] = DB::field("SELECT count(*) FROM users");
1414
$data['users'] = DB::rows("SELECT id, username FROM users LIMIT 500");
15-
\System\Display::template('List Users', 'user_manager/users.list', $data);
15+
\System\Display::template('List Users - User Manager', 'user_manager/users.list', $data);
1616
}
1717

1818
function create()
@@ -23,7 +23,7 @@ function create()
2323
$_SESSION['success_messages'][] = 'User [' . $id . '] ' . $_POST['username'] . ' created.';
2424
header('location:'.BASEURL.'user_manager/users/list'); die();
2525
}
26-
\System\Display::template('Create User', 'user_manager/users.create', $data);
26+
\System\Display::template('Create User - User Manager', 'user_manager/users.create', $data);
2727
}
2828

2929
function delete()

application/packages/user_manager/views/menu.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
<h1>User Manager - <?=$content_title?></h1>
2-
31
<a href="<?=BASEURL?>user_manager/users/list">List Users</a> :
42
<a href="<?=BASEURL?>user_manager/users/create">Create User</a>
53

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
namespace Controllers\Libraries;
3+
class form_validation extends \System\Controller
4+
{
5+
function index()
6+
{
7+
$data['form'] = $form = new \Libraries\IXT_Form_Validation();
8+
9+
if ($_SERVER['REQUEST_METHOD']=='POST')
10+
{
11+
$rules_array = array(
12+
array('first_name', 'First Name', 'required|min_length[2]'),
13+
array('last_name', 'Last Name', 'required|min_length[2]'),
14+
array('email', 'Email', 'required|email'),
15+
array('number', 'Number', 'required|numeric'),
16+
array('integer', 'Integer', 'integer'),
17+
array('decimal', 'Decimal', 'required|decimal|range[10,20]')
18+
);
19+
$form->set_rules($rules_array);
20+
$form->validate($_POST);
21+
22+
if (strpos($_POST['underscore'],'_')===false)
23+
$form->set_error('underscore', 'The Underscore field must contain an underscore.');
24+
}
25+
\System\Display::template('Form Validation', 'libraries/form_validation.index', $data);
26+
}
27+
}

application/source/views/index.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
<h1>Libraries</h1>
1+
<h2>Libraries</h2>
22
<ul>
33
<li><a href="<?=BASEURL?>libraries/form_validation">\Libraries\IXT_Form_Validation</a></li>
44
<li><a href="<?=BASEURL?>libraries/stopwatch">\Libraries\IXT_Stopwatch</a></li>
55
</ul>
66

7-
<h1>Demo Apps</h1>
7+
<h2>Demo Apps</h2>
88
<ul>
99
<li><a href="<?=BASEURL?>user_manager/">User Manager</a></li>
1010
</ul>
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<style type="text/css">
2+
#tbl_form th { text-align: right; }
3+
.error { color: #F00; }
4+
.success { color: #0A0; font-size: 30px; }
5+
</style>
6+
7+
<? $form->set_delim('<li class="error">','</li>'); ?>
8+
9+
<? if ($form->checked_invalid()): ?>
10+
<ul style="border: 1px solid red; margin: 20px;">
11+
<?=$form->get_errors()?>
12+
</ul>
13+
<? endif; ?>
14+
15+
<? $form->set_delim('<span class="error">','</span>'); ?>
16+
17+
<form method="post" action="">
18+
<table id="tbl_form">
19+
<tr>
20+
<th>First Name: </th>
21+
<td><input type="text" name="first_name" value="<?=$form->form_value('first_name','First')?>" /> <?=$form->get_error('first_name')?></td>
22+
</tr>
23+
<tr>
24+
<th>Last Name: </th>
25+
<td><input type="text" name="last_name" value="<?=$form->form_value('last_name','Last')?>" /> <?=$form->get_error('last_name')?></td>
26+
</tr>
27+
<tr>
28+
<th>E-mail: </th>
29+
<td><input type="text" name="email" value="<?=$form->form_value('email','user@email.com')?>" /> <?=$form->get_error('email')?></td>
30+
</tr>
31+
<tr>
32+
<th>Number: </th>
33+
<td><input type="text" name="number" value="<?=$form->form_value('number','0xFF')?>" /> <?=$form->get_error('number')?></td>
34+
</tr>
35+
<tr>
36+
<th>Integer: </th>
37+
<td><input type="text" name="integer" value="<?=$form->form_value('integer','7')?>" />(Not Required) <?=$form->get_error('integer')?></td>
38+
</tr>
39+
<tr>
40+
<th>Decimal: </th>
41+
<td><input type="text" name="decimal" value="<?=$form->form_value('decimal','11.5')?>" />(10-20) <?=$form->get_error('decimal')?></td>
42+
</tr>
43+
<tr>
44+
<th>Underscore: </th>
45+
<td><input type="text" name="underscore" value="<?=$form->form_value('underscore','a_b')?>" /> <?=$form->get_error('underscore')?></td>
46+
</tr>
47+
<tr>
48+
<th>&nbsp;</th>
49+
<td><input type="submit" value="Submit" /></td>
50+
</tr>
51+
</table>
52+
</form>
53+
54+
<? if ($form->checked_valid()): ?>
55+
<br />
56+
<span class="success">SUCCESS</span>
57+
<? endif; ?>

application/templates/main.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
</ul>
1717
</div>
1818
<div id="content">
19-
<? \System\Display::view($content_view, $data); ?>
19+
<h1 id="content_title"><?=$content_title?></h1>
20+
<? \System\Display::view($content_view, $data); ?>
2021
</div>
2122
<div id="footer">
2223
<p style="text-align: center;">&copy; 2011 Website Duck LLC</p>

assets/css/ignitext.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ html, body { padding: 0; margin: 0; }
1212
#header_menu ul li a:hover { text-shadow: 0 0 5px #FFF, 0 0 5px #FFF, 0 0 5px #FFF, 0 0 5px #FFF; }
1313

1414
#content { padding: 20px; }
15+
#content h1 { color: #333; font-size: 30px; }
16+
#content h2 { color: #333; }
1517

1618
#footer { padding: 20px; margin-top: 100px; background-color: #DDD; border: 1px solid #AAA; color: #555; }
1719
#footer a { color: #333; }
20+

0 commit comments

Comments
 (0)