Skip to content
Browse files

Edited form.update.php template to verify that fields array exist bef…

…ore trying to loop it. Fixes #68
  • Loading branch information...
1 parent 885bc02 commit 135673e435dcfb3a3f4a4fdf9ce9cd9fb7d83cd6 @soonick committed May 5, 2012
Showing with 61 additions and 58 deletions.
  1. +1 −0 cache/.gitignore
  2. +60 −58 themes/default/subscribe/form.update.php
View
1 cache/.gitignore
@@ -0,0 +1 @@
+ERROR_LOG_OLD
View
118 themes/default/subscribe/form.update.php
@@ -39,64 +39,67 @@
</div>
<?php
- foreach ($this->fields as $key => $field)
- {
- ?>
- <div>
- <!-- DON'T DISPLAY COMMENT FIELDS ON UPDATE FORM. A COMMENT FIELD
- IS PROVIDED @ user/update.php FOR UNSUBSCRIBE -->
- <?php
- if ('comment' != $field['type'])
- {
- ?>
- <label
- <?php
- if ('on' == $field['required'])
- {
- echo 'class="required"';
- }
- ?> for="field<?php echo $key; ?>">
- <?php echo $field['name']; ?>:
- </label>
- <?php
- }
+ if (!empty($this->fields) && is_array($this->fields))
+ {
+ foreach ($this->fields as $key => $field)
+ {
+ ?>
+ <div>
+ <!-- DON'T DISPLAY COMMENT FIELDS ON UPDATE FORM. A COMMENT FIELD
+ IS PROVIDED @ user/update.php FOR UNSUBSCRIBE -->
+ <?php
+ if ('comment' != $field['type'])
+ {
+ ?>
+ <label
+ <?php
+ if ('on' == $field['required'])
+ {
+ echo 'class="required"';
+ }
+ ?> for="field<?php echo $key; ?>">
+ <?php echo $field['name']; ?>:
+ </label>
+ <?php
+ }
- switch ($field['type'])
- {
- case 'checkbox':
- echo '<input type="checkbox" name="d['.$key.']"
- id="field'.$key.'"'.('on' == $this->d[$key] ?
- ' checked="checked" ' : '').' />';
- break;
- case 'multiple':
- echo '<select name="d['.$key.']" id="field'.$key.'">';
- echo
- '<option value="">'
- ._('Choose Selection')
- .'</option>';
- foreach ($field['array'] as $option)
- {
- echo
- '<option '.($option == $this->d[$key] ?
- ' selected="selected" ' : '').'>'
- .$option
- .'</option>';
- }
- echo '</select>';
- break;
- default:
- echo '<input type="text" '.('date' == $field['type'] ?
- 'class="text datepicker" size="12" ' :
- 'size="32" ').'name="d['.$key.']"
- id="field'.$key.'" '.(isset($this->d[$key]) ?
- ' value="'.htmlentities($this->d[$key]).'" ' :
- '').' />';
- break;
- }
- ?>
- </div>
- <?php
- }
+ switch ($field['type'])
+ {
+ case 'checkbox':
+ echo '<input type="checkbox" name="d['.$key.']"
+ id="field'.$key.'"'.('on' == $this->d[$key] ?
+ ' checked="checked" ' : '').' />';
+ break;
+ case 'multiple':
+ echo '<select name="d['.$key.']" id="field'.$key.'">';
+ echo
+ '<option value="">'
+ ._('Choose Selection')
+ .'</option>';
+ foreach ($field['array'] as $option)
+ {
+ echo
+ '<option '.($option == $this->d[$key] ?
+ ' selected="selected" ' : '').'>'
+ .$option
+ .'</option>';
+ }
+ echo '</select>';
+ break;
+ default:
+ echo '<input type="text" '.('date' == $field['type'] ?
+ 'class="text datepicker" size="12" ' :
+ 'size="32" ').'name="d['.$key.']"
+ id="field'.$key.'" '.(isset($this->d[$key]) ?
+ ' value="'.htmlentities($this->d[$key]).'" ' :
+ '').' />';
+ break;
+ }
+ ?>
+ </div>
+ <?php
+ }
+ }
?>
</fieldset>
@@ -106,4 +109,3 @@
</div>
</form>
</div>
-

0 comments on commit 135673e

Please sign in to comment.
Something went wrong with that request. Please try again.