Skip to content

Commit a69ab80

Browse files
committed
Build currencies list for Currency and Accounting Wizards
1 parent 32b4dfb commit a69ab80

File tree

2 files changed

+26
-12
lines changed

2 files changed

+26
-12
lines changed

samples/Wizards/NumberFormat/Accounting.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@
1414

1515
return;
1616
}
17+
18+
$currencies = [
19+
'$' => 'US Dollars ($)',
20+
'' => 'Euro (€)',
21+
'¥' => 'Japanese Yen (¥)',
22+
'£' => 'Pound Sterling (£)',
23+
'' => 'Rupee (₹)',
24+
'' => 'Rouble (₽)',
25+
];
26+
1727
?>
1828
<form action=Accounting.php method="POST">
1929
<div class="mb-3 row">
@@ -29,12 +39,9 @@
2939
<label for="currency" class="col-sm-2 col-form-label">Currency</label>
3040
<div class="col-sm-10">
3141
<select name="currency" class="form-select">
32-
<option value="$" <?php echo (isset($_POST['currency']) && $_POST['currency'] === '$') ? 'selected' : ''; ?>>US Dollars ($)</option>
33-
<option value="€" <?php echo (isset($_POST['currency']) && $_POST['currency'] === '') ? 'selected' : ''; ?>>Euro (€)</option>
34-
<option value="¥" <?php echo (isset($_POST['currency']) && $_POST['currency'] === '¥') ? 'selected' : ''; ?>>Japanese Yen (¥)</option>
35-
<option value="£" <?php echo (isset($_POST['currency']) && $_POST['currency'] === '£') ? 'selected' : ''; ?>>Pound Sterling (£)</option>
36-
<option value="₹" <?php echo (isset($_POST['currency']) && $_POST['currency'] === '') ? 'selected' : ''; ?>>Rupee (₹)</option>
37-
<option value="₽" <?php echo (isset($_POST['currency']) && $_POST['currency'] === '') ? 'selected' : ''; ?>>Rouble (₽)</option>
42+
<?php foreach ($currencies as $currencySymbol => $currencyName) {
43+
echo "<option value=\"{$currencySymbol}\" " . ((isset($_POST['currency']) && $_POST['currency'] === $currencySymbol) ? 'selected' : '') . ">{$currencyName}</option>", PHP_EOL;
44+
} ?>
3845
</select>
3946
</div>
4047
</div>

samples/Wizards/NumberFormat/Currency.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@
1414

1515
return;
1616
}
17+
18+
$currencies = [
19+
'$' => 'US Dollars ($)',
20+
'' => 'Euro (€)',
21+
'¥' => 'Japanese Yen (¥)',
22+
'£' => 'Pound Sterling (£)',
23+
'' => 'Rupee (₹)',
24+
'' => 'Rouble (₽)',
25+
];
26+
1727
?>
1828
<form action="Currency.php" method="POST">
1929
<div class="mb-3 row">
@@ -29,12 +39,9 @@
2939
<label for="currency" class="col-sm-2 col-form-label">Currency</label>
3040
<div class="col-sm-10">
3141
<select name="currency" class="form-select">
32-
<option value="$" <?php echo (isset($_POST['currency']) && $_POST['currency'] === '$') ? 'selected' : ''; ?>>US Dollars ($)</option>
33-
<option value="€" <?php echo (isset($_POST['currency']) && $_POST['currency'] === '') ? 'selected' : ''; ?>>Euro (€)</option>
34-
<option value="¥" <?php echo (isset($_POST['currency']) && $_POST['currency'] === '¥') ? 'selected' : ''; ?>>Japanese Yen (¥)</option>
35-
<option value="£" <?php echo (isset($_POST['currency']) && $_POST['currency'] === '£') ? 'selected' : ''; ?>>Pound Sterling (£)</option>
36-
<option value="₹" <?php echo (isset($_POST['currency']) && $_POST['currency'] === '') ? 'selected' : ''; ?>>Rupee (₹)</option>
37-
<option value="₽" <?php echo (isset($_POST['currency']) && $_POST['currency'] === '') ? 'selected' : ''; ?>>Rouble (₽)</option>
42+
<?php foreach ($currencies as $currencySymbol => $currencyName) {
43+
echo "<option value=\"{$currencySymbol}\" " . ((isset($_POST['currency']) && $_POST['currency'] === $currencySymbol) ? 'selected' : '') . ">{$currencyName}</option>", PHP_EOL;
44+
} ?>
3845
</select>
3946
</div>
4047
</div>

0 commit comments

Comments
 (0)