Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logic to add class names based on field ID and passing the field ID to the element param of pmpro_get_element_class so form processing can target #3251

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions classes/class-pmpro-field-group.php
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,10 @@ public function display( $args = array() ) {
$field->divclass .= "pmpro_form_field pmpro_form_field-" . $field->type;
$field->class .= " pmpro_form_input-" . $field->type;

// Add a class to the field based on the id.
$field->divclass .= " pmpro_form_field-" . $field->id;
$field->class .= " pmpro_form_input-" . $field->id;

// Add the required class to field.
if ( ! empty( $args['show_required'] ) && ! empty( $field->required ) ) {
$field->divclass .= " pmpro_form_field-required";
Expand All @@ -463,8 +467,8 @@ public function display( $args = array() ) {
}

// Run the class through the filter.
$field->divclass = pmpro_get_element_class( $field->divclass );
$field->class = pmpro_get_element_class( $field->class );
$field->divclass = pmpro_get_element_class( $field->divclass, $field->id );
$field->class = pmpro_get_element_class( $field->class, $field->id );

?>
<div id="<?php echo esc_attr( $field->id );?>_div" <?php if ( ! empty( $field->divclass ) ) { echo 'class="' . esc_attr( $field->divclass ) . '"'; } ?>>
Expand Down