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

Noticed that this doesn't work for repeating fields in a group. #3

Open
garypaul opened this issue Oct 30, 2019 · 2 comments
Open

Noticed that this doesn't work for repeating fields in a group. #3

garypaul opened this issue Oct 30, 2019 · 2 comments

Comments

@garypaul
Copy link

Issue

When you have a repeated text box in a group, it doesn't trigger the isGroup variable. If you manually change that var (testing in debugging) to true, it hides, the Text box itself, but not the whole row.

SAMPLE CODE to Replicate issue:

Add cmb2 box:

$cmb_box = new_cmb2_box( [
  'id'            => 'prefix_mybox',
   'title'         => 'My Box',
  'object_types'  => ['options-page'],
  'option_key'    => 'prefix_settings',
]);

$group_id = $cmb_box->add_field([
  'id'            => 'product_attribute_map',
  'type'          => 'group',
]);

Add trigger field and conditional repeating text field

$cmb_box->add_group_field( $group_id, [
  'id' = 'show_repeating_text',
  'type' => 'select',
  'options' => [ 
    'show' => 'Show',
    'hide'  => 'Hide',
  ]);

$cmb_box->add_group_field( $group_id, [
  'id' => 'mylist',
  'type' => 'text',
  'repeatable' => true,
  'attributes' => [
      'data-conditional-id' => 'show_repeating_text',
      'data-conditional-value' => 'show',
  ],
]);
@maxjutras
Copy link

+1 for this

@zohrabi71
Copy link

add this code in the js:

// Create a <style> tag
var style = $('<style></style>').append('.field_is_hidden {display: none;}');

// Append the <style> tag to the <head>
$('head').append(style);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants