Skip Navigation

[Resolved] Conditional fields in form: input fields not showing, only labels

This support ticket is created 3 years ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 3 replies, has 2 voices.

Last updated by Roberto Miguez 3 years ago.

Assisted by: Minesh.

Author
Posts
#2242537

Tell us what you are trying to do?

I have a "create post" frontend form with a conditional group from a dropdown select. When a value is selected, some extra fields must be shown. The conditional works well, but only the labels are shown, not the fields. I see this is caused by a style="height:auto; display:none;" that appears in the div that wraps the input fields in the frontend output.

I guess that when the condition is active (option selected), the style will be changed to display the fields, but somehow this is not happening.

The problem remains no matter I use the visual GUI or the "expert mode" to edit the form.

What is the link to your site?

hidden link

#2243167

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Can you please share admin access details so I can check whats going wrong with your setup.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2243493

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

The reason why it was not working because you have also setup post field conditional display with your custom field group for the fields 'numero-de-ninos','edades','colegio'. The conditional display you set in the backed was having conflict on frontend.
=> hidden link

To fix that, I've added the following filter code to "Custom Code" section offered by Toolset with code snippet "toolset-custom-code":
=> hidden link

add_filter('cred_filter_field_before_add_to_form', 'func_adjust_conflict_conditions', 10, 1);
function func_adjust_conflict_conditions($field){
   $form_id = 0;
   $form_html_id = $field['form_html_id'];
   
   if ( isset($form_html_id) ) {
        $parts = explode( '_', $form_html_id);
        $form_id = (int) $parts[2];
    }
    
    $field_slugs = array('numero-de-ninos','edades','colegio');
    if($form_id==72 and in_array($field['id'],$field_slugs)){
       // in some cases $fields['data'] is an empty string, so you'll need to first set it's expected format for PHP 7.1 compatibility
        if (!is_array($field['data'])) {
            $field['data'] = array();
        }
        $field['data']['conditional_display'] = array();
 
       
    }
    return $field;
}

I can see its working as expected with the form now: hidden link

#2244101

Oh, I see...

Thank you very much for your help, Minesh.