FireWire Posted January 15 Posted January 15 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.
bernhard Posted January 21 Posted January 21 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; }
FireWire Posted January 21 Author Posted January 21 Copied and pasted, still not working for me. Not sure what it is but if it's working for you it has to be some sort of conflict on my end. When I have time I'll do some digging and come back with anything I find. Thanks for checking it out!
bernhard Posted January 21 Posted January 21 Thx! Maybe anybody else can try it also @gebeer @Stefanowitsch ?
Stefanowitsch Posted January 21 Posted January 21 I can confirm that this example code from the docs is working for me: $settings->add([ 'name' => 'showImages', 'label' => 'Show Items with Images', 'value' => $field->input('showImages', 'checkbox'), ]); $settings->add([ 'name' => 'noBackground', 'label' => 'Do not add blurred background behind images', 'value' => $field->input('noBackground', 'checkbox'), 'showIf' => 'showImages=1', ]); @FireWire your code example is working too in my case: $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', ]); 2
FireWire Posted January 21 Author Posted January 21 @Stefanowitsch Thank you very much for taking the time to check. It's gotta be something odd on my end or some conflict unique to my case.
bernhard Posted January 23 Posted January 23 @Spinbox thx for your report, but it would be nice if you could also try to add helpful information to your report rather than just a short "not working" note. Please try different browsers, etc.; Multi-Language yes/no etc.? Console errors? ... 1
FireWire Posted January 28 Author Posted January 28 @bernhard I'll do some more testing myself and come back with anything I can find. 1
Spinbox Posted April 8 Posted April 8 (edited) @bernhard for me it was using 'radios' when trying 'showIf' => 'layoutPanel=2', // Works $settings->add([ 'name' => 'layoutPanel', 'label' => 'Layout Panel', 'value' => $field->input('layoutPanel', 'select', [ '*1' => 'Closed', '2' => 'Open', ]), ]); // Doesnt work $settings->add([ 'name' => 'layoutPanel', 'label' => 'Layout Panel', 'value' => $field->input('layoutPanel', 'radios', [ '*1' => 'Closed', '2' => 'Open', ]), ]); Edit: And to add to this; would it be possible to implement more showIf conditions? like 'showIf' => 'layoutPanel=2,layoutPaddingMode=single' Edited April 8 by Spinbox
bernhard Posted July 20 Posted July 20 Hey @Spinbox I have just added support for showIf also checking other form fields on the block (not only other settings) and it now supports complex conditions like these: 'showIf' => 'advancedOptions=1 && (layout=grid || layout=list)', 'showIf' => 'whatever=1 || text="foo bar"', https://www.baumrock.com/en/processwire/modules/rockpagebuilder/docs/settings/#conditionals-showif 1
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now