I use the uniform plugin for a contact and a newsletter form on my website. In the template, i use one of the following error snippets in case of wrong input:
- form/error-contact
<?php if ($contactform->error($field)): ?>
<p class="error"><?php echo implode('<br>', $contactform->error($field)) ?></p>
<?php endif; ?>
- form/error-newsletter
<?php if ($newsletterform->error($field)): ?>
<p class="error"><?php echo implode('<br>', $newsletterform->error($field)) ?></p>
<?php endif; ?>
The contents of both snippets is the same except the form variable. I would like to combine it to one snippet ‘form/error’ but can’t figure out how to check if the $contactform or $newsletterform variable exists and avoid an ‘undefined variable error’.
In case it is important: i use a hidden input form-id with value “contact” or “newsletter” to identify the form.
Any ideas?