jcchavezs / cmb2-conditionals

Plugin to relate fields in a CMB2 metabox
GNU General Public License v2.0
85 stars 61 forks source link

conditional cmb2 works in back end but not in front end #61

Open dackr opened 6 years ago

dackr commented 6 years ago

install conditional cmb2 and it works in the back end. I managed to call the file cmb2-conditionals.js to the front end but the ocndicional does not work I have put the ID of the field. please help PS I have seen the related posts but they did not help me I have tried several things.

This is the code that works well in Back end but does not work in the front end. call script in function.php

wp_enqueue_script('cmb2-conditionals', plugins_url('/cmb2-conditionals.js', 'path/to/CMB2_conditionals/file'), array('jquery'), '1.0.2', true);


$prefix = LISTING_PREFIX . IGLESIAS_PREFIX;

$field_id = LISTING_PREFIX . IGLESIAS_PREFIX . 'tributos_prediales_resolucion';
        if ( apply_filters( 'inventor_metabox_field_enabled', true, $metabox_id, $field_id, $post_type ) ) {
            $predial->add_field( array(
                'id'            => $field_id,
                'type'          => 'radio',
                'name'          => __( '¿Tiene Resolución de Inafectación?', 'xxx' ),
                'description'   => __( 'Seleccione si o no', 'xxx' ),
                'options'       => array(
                    'no'     => __( 'NO', 'xx' ),
                    'si'        => __( 'SI', 'xx' ),
                ),
                'attributes' => array(
                    'data-conditional-id'    => $prefix . 'tributos_prediales',
                    'data-conditional-value' => 'si',
                ),
            ) );
        }

thanks for your Help Friends