Commit d4bd798b authored by Kevin Atkinson's avatar Kevin Atkinson

Use foreach instead of while (...each) when iterating through $fields,

it's less error prone.  That is change:
  while (list ($name, $attributes) = each ($fields)) {
to
  foreach ($fields as $name => $attributes) {

This fixes a bug which caused an empty form to display in
submitpub.php.

When using while (...each) it is important to call reset, before the
loop to reset the internal array iterator.  We don't ever seam to do
this, and its clearer to just use foreach.

Someone, eventually, should probably fix all the other cases of using
each in a while loop, just in case.  But that fix is for another day.
parent 836149bb
......@@ -420,7 +420,7 @@ function FormRenderElements($fields, $submitted)
global $footnotes;
$html = "";
while (list ($name, $attributes) = each ($fields)) {
foreach ($fields as $name => $attributes) {
$field_html = FormRenderElement($name, $attributes, $submitted);
if ($field_html) {
......@@ -654,7 +654,7 @@ function FormValidateFileUpload($name, &$errors, $attributes)
function FormValidate($form, &$errors, $fields, &$submitted, $parent_label = '')
{
while (list ($name, $attributes) = each ($fields)) {
foreach ($fields as $name => $attributes) {
switch ($attributes['#type']) {
case "textfield":
case "password":
......@@ -724,7 +724,7 @@ function FormTextDumpElement($name, $attributes, $values, $label_width, $parent_
function FormTextDump($form, $fields, $values, $label_width = 20, $parent_label = '')
{
$res = '';
while (list ($name, $attributes) = each ($fields)) {
foreach ($fields as $name => $attributes) {
switch ($attributes['#type']) {
case "hidden":
case "textfield":
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment