This topic contains 2 replies, has 2 voices, and was last updated by Alex Kladov 5 months, 2 weeks ago.
-
AuthorPosts
-
August 8, 2018 at 6:35 pm #9196
Hi,
I noticed that the field conditions don’t work, when they depend on hidden field’s value.
The situation is, I have a plugin, which I am writing a settings page for. The Workflow has multiple tabs, the first tab allows the user to enable/disable this plugin by clicking a checkbox field called “enabled”. And since I couldn’t find a way to directly “hook” into the “enabled” field from other workflow tabs, I was thinking to use a hidden field and populate the value of this field dynamically on every page load. This is what I had:
$plugin_settings = get_option( 'plugin_settings' ); piklist( 'field', array( 'type' => 'hidden', 'field' => 'is_enabled', 'value' => ( array_key_exists( 'enabled', $plugin_settings ) && $plugin_settings['enabled'] == 'true' ), ) ); piklist( 'field', array( 'type' => 'text', 'field' => 'dependent_field', 'label' => 'Dependent Field', 'conditions' => array( array( 'field' => 'is_enabled', 'value' => true, 'reset' => false, ), ), ));
But it doesn’t work. It only works, if the “is_enabled” is not of type “hidden”. Is this a bug or an expected behaviour?
Also, does anyone know how else I can hide fields based on other filed’s value from another workflow tab? Or, even better, how can I hide entire Wokflow tabs, based on Setting field value?
Regards,
Alex -
August 20, 2018 at 2:09 pm #9199
Alex– You can filter the comment block any Piklist
part
by using thepiklist_part_process_callback
filter.This tutorial uses this filter to add the user role “no-role” is certain conditions apply. You can do the same with Workflow tab.
https://docs.piklist.com/tutorials/meta-boxes/hide-meta-boxes-page-template/
-
September 6, 2018 at 6:01 pm #9212
Hi Steve,
Thanks for pointing that out! That seems to be what I was looking for so far. Do you perhaps have a code snippet that does what I am looking for (i.e. hide tabs based on Piklist settings page value)?
Also, what about the dependency on hidden fields? Is this expected behaviour or did I stumble onto a bug?
Regards,
Alex -
AuthorPosts
You must be logged in to reply to this topic.