Jump to content

Settings showIf not showing if


FireWire
 Share

Recommended Posts

I tried to create a showIf with two select fields but couldn't get it to work properly. I copy/pasted the example from the docs directly in case I was missing something but I still can't get it to work.

My attempt:

<?php

$settings->add([
    'name' => 'image_location_horizontal',
    'label' => 'Image Location',
    'value' => $field->input('image_location_horizontal', 'select', [
        '*right' => 'Right',
        'left' => 'Left',
        'center' => 'Center',
    ]),
]);

$settings->add([
    'name' => 'body_location_vertical',
    'label' => 'Body Location',
    'value' => $field->input('body_location_vertical', 'select', [
        '*above_feature' => 'Above Feature',
        'below_feature' => 'Below Feature',
    ]),
    'showIf' => 'image_location_horizontal=center',
]);

Tried searching to see if this has come up for anyone else but didn't see anything.

Link to comment
Share on other sites

Hey @FireWire when working on the new settings syntax & docs I tried this example and it worked as expected: https://www.baumrock.com/en/processwire/modules/rockpagebuilder/docs/settings/#conditionals-showif

Is this still an issue for you?

I just checked with your example and everything works as expected there as well!


  /**
   * (Optional) Settings of this block
   *
   * You can access settings of the block via $block->settings() or access
   * a single setting via $block->settings('foo') or $block->settings('bar')
   *
   * If you don't want any settings for your block you can remove this method.
   */
  public function settingsTable(\ProcessWire\RockFieldsField $field)
  {
    $settings = $this->getSettings();

    $settings->add([
      'name' => 'image_location_horizontal',
      'label' => 'Image Location',
      'value' => $field->input('image_location_horizontal', 'select', [
        '*right' => 'Right',
        'left' => 'Left',
        'center' => 'Center',
      ]),
    ]);

    $settings->add([
      'name' => 'body_location_vertical',
      'label' => 'Body Location',
      'value' => $field->input('body_location_vertical', 'select', [
        '*above_feature' => 'Above Feature',
        'below_feature' => 'Below Feature',
      ]),
      'showIf' => 'image_location_horizontal=center',
    ]);

    return $settings;
  }

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   1 member

×
×
  • Create New...