Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 07c9b68

Browse files
committed
Modernization: array() is now [].. removed old <meta> tag.
1 parent 602d595 commit 07c9b68

File tree

4 files changed

+27
-31
lines changed

4 files changed

+27
-31
lines changed

‎examples/advanced.php‎

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,29 @@
1313
);
1414

1515
// Add text inputs. (input type, name/id, default data, validation flags, label, helper message, validation warning message).
16-
$form->add('realname', 'text', 'Default text.', array('required'), 'Name', '', 'Your name is required.');
17-
$form->add('username', 'text', '', array('required', 'lengthmin 2'), 'Screen Name', '', 'Your screen name is required.');
18-
$form->add('email', 'text', '', array('required', 'email'), 'Email', '', 'Your email is required.');
19-
$form->add('phone', 'text', '', array('phone'), 'Phone Number', 'We\'ll send you a quick reminder the day before the event!', 'Your phone number must be valid.');
16+
$form->add('realname', 'text', 'Default text.', ['required'], 'Name', '', 'Your name is required.');
17+
$form->add('username', 'text', '', ['required', 'lengthmin 2'], 'Screen Name', '', 'Your screen name is required.');
18+
$form->add('email', 'text', '', ['required', 'email'], 'Email', '', 'Your email is required.');
19+
$form->add('phone', 'text', '', ['phone'], 'Phone Number', 'We\'ll send you a quick reminder the day before the event!', 'Your phone number must be valid.');
2020

2121
// Add text area.
22-
$form->add('suggestions', 'textarea', '', array(''), 'Suggestion Box', 'Have your voice heard!', '');
22+
$form->add('suggestions', 'textarea', '', [''], 'Suggestion Box', 'Have your voice heard!', '');
2323

2424
// Add drop down list.
25-
$form->add('race', 'dropdown', '', array('required'), 'Your Race', '', 'Your selection is required.');
25+
$form->add('race', 'dropdown', '', ['required'], 'Your Race', '', 'Your selection is required.');
2626
$form->addDropdownEntry('race', 'Ready to roll out! (Terran)', 'terran');
2727
$form->addDropdownEntry('race', 'My life for Auir! (Protoss)', 'protoss');
2828
$form->addDropdownEntry('race', 'Here\'s for the swarm! (Zerg)', 'zerg');
2929
$form->addDropdownEntry('race', 'Ballin out of control! (Random)', 'random');
3030

3131
// Add radio button list.
32-
$form->add('beverage', 'radio', '', array('required'), 'Preferred Beverage', '', 'Your selection is required.');
32+
$form->add('beverage', 'radio', '', ['required'], 'Preferred Beverage', '', 'Your selection is required.');
3333
$form->addRadioButton('beverage', 'Coffee', 0);
3434
$form->addRadioButton('beverage', 'Tea', 1);
3535
$form->addRadioButton('beverage', 'Bawls', 2);
3636

3737
// Add check box.
38-
$form->add('notify', 'checkbox', true, array(''), 'Notify me of future gaming events in my area.', '', '');
38+
$form->add('notify', 'checkbox', true, [''], 'Notify me of future gaming events in my area.', '', '');
3939

4040
// Did the form validate successfully?
4141
if($form->validate())
@@ -83,8 +83,7 @@
8383
try
8484
{
8585
// Connect to Database.
86-
$dbh = new PDO("mysql:host=".DB_HOST.";dbname=".DB_NAME.";port=".DB_HOST_PORT, DB_USER, DB_PASSWORD, array( PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING ));
87-
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
86+
$dbh = new PDO("mysql:host=".DB_HOST.";dbname=".DB_NAME.";port=".DB_HOST_PORT, DB_USER, DB_PASSWORD, [PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING ]);
8887

8988
// Is this email already registered?
9089
$query = $dbh->prepare("SELECT email FROM attendees WHERE email=:email LIMIT 1");
@@ -135,10 +134,9 @@
135134
<!DOCTYPE html>
136135
<html>
137136
<head>
138-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
139137
<title>SimplePHPForm Advanced Example</title>
140138
<link rel="stylesheet" type="text/css" media="screen" href="css/simplephpform_default.css" />
141-
</head>
139+
</head>
142140
<body>
143141
<?php echo $form->displayState(); ?>
144142
<form method="post" action="advanced.php" class="simplephpform">

‎examples/basic.php‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
require('../SimplePHPForm.php');
33

44
$form = new SimplePHPForm();
5-
$form->add('name', 'text', '', array('required'), 'Name', '', 'Your name is required.');
6-
$form->add('email', 'text', '', array('required', 'email'), 'Email', '', 'Your email is required.');
5+
$form->add('name', 'text', '', ['required'], 'Name', '', 'Your name is required.');
6+
$form->add('email', 'text', '', ['required', 'email'], 'Email', '', 'Your email is required.');
77

88
if($form->validate()) // Did the form validate successfully?
99
{
@@ -16,10 +16,9 @@
1616
<!DOCTYPE html>
1717
<html>
1818
<head>
19-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
2019
<title>SimplePHPForm Basic Example</title>
2120
<link rel="stylesheet" type="text/css" media="screen" href="css/simplephpform_default.css" />
22-
</head>
21+
</head>
2322
<body>
2423
<?php echo $form->display(); ?>
2524
</body>

‎examples/centered.php‎

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,29 @@
77
$form = new SimplePHPForm('centered.php');
88

99
// Add text inputs. (input type, name/id, default data, validation flags, label, helper message, validation warning message).
10-
$form->add('realname', 'text', 'Default text.', array('required'), 'Name', '', 'Your name is required.');
11-
$form->add('username', 'text', '', array('required'), 'Screen Name', '', 'Your screen name is required.');
12-
$form->add('email', 'text', '', array('required', 'email'), 'Email', '', 'Your email is required.');
13-
$form->add('phone', 'text', '', array('phone'), 'Phone Number', 'We\'ll send you a quick reminder the day before the event!', 'Your phone number must be valid.');
10+
$form->add('realname', 'text', 'Default text.', ['required'], 'Name', '', 'Your name is required.');
11+
$form->add('username', 'text', '', ['required'], 'Screen Name', '', 'Your screen name is required.');
12+
$form->add('email', 'text', '', ['required', 'email'], 'Email', '', 'Your email is required.');
13+
$form->add('phone', 'text', '', ['phone'], 'Phone Number', 'We\'ll send you a quick reminder the day before the event!', 'Your phone number must be valid.');
1414

1515
// Add drop down list.
16-
$form->add('race', 'dropdown', '', array('required'), 'Your Race', '', 'Your selection is required.');
16+
$form->add('race', 'dropdown', '', ['required'], 'Your Race', '', 'Your selection is required.');
1717
$form->addDropdownEntry('race', 'Ready to roll out! (Terran)', 'terran');
1818
$form->addDropdownEntry('race', 'My life for Auir! (Protoss)', 'protoss');
1919
$form->addDropdownEntry('race', 'Here\'s for the swarm! (Zerg)', 'zerg');
2020
$form->addDropdownEntry('race', 'Ballin out of control! (Random)', 'random');
2121

2222
// Add radio button list.
23-
$form->add('beverage', 'radio', '', array('required'), 'Preferred Beverage', '', 'Your selection is required.');
23+
$form->add('beverage', 'radio', '', ['required'], 'Preferred Beverage', '', 'Your selection is required.');
2424
$form->addRadioButton('beverage', 'Coffee', 0);
2525
$form->addRadioButton('beverage', 'Tea', 1);
2626
$form->addRadioButton('beverage', 'Bawls', 2);
2727

2828
// Add text area.
29-
$form->add('suggestions', 'textarea', '', array(''), 'Suggestion Box', 'Have your voice heard!', '');
29+
$form->add('suggestions', 'textarea', '', [''], 'Suggestion Box', 'Have your voice heard!', '');
3030

3131
// Add check box.
32-
$form->add('notify', 'checkbox', true, array(''), 'Notify me of future gaming events in my area.', '', '');
32+
$form->add('notify', 'checkbox', true, [''], 'Notify me of future gaming events in my area.', '', '');
3333

3434
// Did the form validate successfully?
3535
if($form->validate())
@@ -44,11 +44,10 @@
4444
<!DOCTYPE html>
4545
<html>
4646
<head>
47-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
4847
<title>SimplePHPForm Centered Example</title>
4948
<link rel="stylesheet" type="text/css" media="screen" href="css/simplephpform_default.css" />
5049
<link rel="stylesheet" type="text/css" media="screen" href="css/simplephpform_center.css" />
51-
</head>
50+
</head>
5251
<body>
5352
<div class="simplephpform_wrapper">
5453
<?php echo $form->display(); ?>

‎tests/SimplePHPFormTest.php‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ public function testDisplayState()
1919
public function testAddText()
2020
{
2121
$form = new SimplePHPForm();
22-
$form->add('name', 'text', '', array('required'), 'Name', '', 'Your name is required.');
22+
$form->add('name', 'text', '', ['required'], 'Name', '', 'Your name is required.');
2323
$this->assertContains('Name', $form->display('name'));
2424
}
2525

2626
public function testAddDropdown()
2727
{
2828
$form = new SimplePHPForm();
29-
$form->add('race', 'dropdown', '', array('required'), 'Your Race', '', 'Your selection is required.');
29+
$form->add('race', 'dropdown', '', ['required'], 'Your Race', '', 'Your selection is required.');
3030
$form->addDropdownEntry('race', 'Ready to roll out! (Terran)', 'terran');
3131
$form->addDropdownEntry('race', 'My life for Auir! (Protoss)', 'protoss');
3232
$form->addDropdownEntry('race', 'Heres for the swarm! (Zerg)', 'zerg');
@@ -38,7 +38,7 @@ public function testAddDropdown()
3838
public function testAddRadioButton()
3939
{
4040
$form = new SimplePHPForm();
41-
$form->add('beverage', 'radio', '', array('required'), 'Preferred Beverage', '', 'Your selection is required.');
41+
$form->add('beverage', 'radio', '', ['required'], 'Preferred Beverage', '', 'Your selection is required.');
4242
$form->addRadioButton('beverage', 'Coffee', 0);
4343
$form->addRadioButton('beverage', 'Tea', 1);
4444
$form->addRadioButton('beverage', 'Bawls', 2);
@@ -48,14 +48,14 @@ public function testAddRadioButton()
4848
public function testAddTextArea()
4949
{
5050
$form = new SimplePHPForm();
51-
$form->add('suggestions', 'textarea', '', array(''), 'Suggestion Box', 'Have your voice heard!', '');
51+
$form->add('suggestions', 'textarea', '', [''], 'Suggestion Box', 'Have your voice heard!', '');
5252
$this->assertContains('<textarea name="simplephpform_suggestions"', $form->display());
5353
}
5454

5555
public function testAddCheckbox()
5656
{
5757
$form = new SimplePHPForm();
58-
$form->add('notify', 'checkbox', true, array(''), 'Notify me of future events in my area.', '', '');
58+
$form->add('notify', 'checkbox', true, [''], 'Notify me of future events in my area.', '', '');
5959
$this->assertContains('<input type="checkbox" name="simplephpform_notify"', $form->display());
6060
}
6161

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /