Last active
March 4, 2026 23:28
-
-
Save xnau/7177eab788cb2d92533be5471e819f4e to your computer and use it in GitHub Desktop.
Shows how to prevent hidden form fields from getting validated in Participants Database
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* | |
| * bootstrap template for signup form | |
| * | |
| * outputs a Twitter Bootstrap-compatible form | |
| * http://twitter.github.com/bootstrap/index.html | |
| * | |
| * | |
| * | |
| */ | |
| ?> | |
| // this script prevents the form attempting to validate input fields that have been hidden by Dynamic Forms | |
| <script> | |
| jQuery(document).ready(function($){ | |
| var form = $(this); | |
| var set_disabled = function(el){ | |
| form.find('input[required]:hidden').prop('disabled',true); | |
| form.find('input[disabled]:visible').prop('disabled',false); | |
| } | |
| $('.pdb-signup form, .pdb-record form').on('change', 'input', set_disabled); | |
| set_disabled(); | |
| }); | |
| </script> | |
| <div class="wrap <?php echo $this->wrap_class ?>" > | |
| <?php // this is how the html wrapper for the error messages can be customized | |
| $this->print_errors( '<div class="alert %1$s">%2$s</div>','<p>%s</p>' ); ?> | |
| <?php $this->print_form_head(); // this must be included before any fields are output ?> | |
| <div class="form-horizontal pdb-signup"> | |
| <?php while ( $this->have_groups() ) : $this->the_group(); ?> | |
| <fieldset class="field-group field-group-<?php echo $this->group->name ?>"> | |
| <?php $this->group->print_title( '<legend>', '</legend>' ) ?> | |
| <?php $this->group->print_description() ?> | |
| <?php while ( $this->have_fields() ) : $this->the_field(); ?> | |
| <?php $feedback_class = $this->field->has_error() ? 'error' : ''; ?> | |
| <div class="<?php $this->field->print_element_class() ?> control-group <?php echo $feedback_class ?>"> | |
| <label class="control-label" for="<?php $this->field->print_element_id() ?>" ><?php $this->field->print_label(); // this function adds the required marker ?></label> | |
| <div class="controls"><?php $this->field->print_element_with_id(); ?> | |
| <?php if ( $this->field->has_help_text() ) :?> | |
| <span class="help-block"> | |
| <?php echo str_replace( '\"', '"', $this->field->help_text ) ?> | |
| </span> | |
| <?php endif ?> | |
| </div> | |
| </div> | |
| <?php endwhile; // fields ?> | |
| </fieldset> | |
| <?php endwhile; // groups ?> | |
| <fieldset class="field-group field-group-submit"> | |
| <div id="submit-button" class="controls"> | |
| <?php $this->print_submit_button('btn btn-primary'); // you can specify a class for the button ?> | |
| <span class="pdb-retrieve-link"><?php $this->print_retrieve_link(__('Forget your private link? Click here to have it emailed to you.','participants-database')); ?></span> | |
| </div> | |
| </fieldset> | |
| </div> | |
| <?php $this->print_form_close() ?> | |
| </div> |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Using Participants Database Custom Templates
The required fields that you are hiding must be text input fields and they must use client-side validation, not plugin validation that is set in the field definition.