Jump to content

Custom Inputfield Dependencies


Robin S

Recommended Posts

  • 2 weeks later...

Thanks for this module! It saved many hours for me. And one more thing i noticed. It has some bugs with toggle field value as dependency and when is used for field_tab
But all other are works grate!)) Thanks again!

Link to comment
Share on other sites

2 hours ago, regesh said:

It has some bugs with toggle field value as dependency and when is used for field_tab

@regesh, that's a pretty vague statement. A proper bug report needs to include an exact description of the bugs and steps to reproduce them. Otherwise it's difficult to respond.

As far as I can see the module works with FieldtypeToggle just fine. If you want to match a Toggle field in a selector you have to use the integer value - that isn't specific to this module, it's the way the PW core works.

2020-07-15_101907.png.d0a8080b04c2e29824c7a791f832867a.png

And by "field_tab" do you mean the core "Fieldset in Tab (Open)" aka FieldtypeFieldsetTabOpen? The module also works fine with this fieldtype so I don't understand the problem.

If instead you are talking about the tab option of the non-core FieldsetGroup module that is part of ProFields then I've added support for that in v0.2.2.

Link to comment
Share on other sites

  • 2 years later...
6 hours ago, gornycreative said:

Would I be able to use this to check if a repeater matrix item has any items assigned? I want to set up a drop down that only appears when a repeater is populated.

Did you try something already and it didn't work?

You should be able to use either the "Show only if page is matched by selector"...

your_matrix_field.count>0

...or the "Show only if custom PHP returns true" setting...

$items = $page->getFormatted('your_matrix_field');
if($items && $items->count) return true;

If you were wanting to do the opposite, i.e. show the field only when the matrix field is empty, then it should work to put "your_matrix_field.count=0" into the "Show only if page is matched by selector" setting but unfortunately there seems to be a core PW bug: https://github.com/processwire/processwire-issues/issues/1701

So until that's fixed you'd need to use the "Show only if custom PHP returns true" setting instead:

$items = $page->getFormatted('your_matrix_field');
if($items && !$items->count) return true;

 

Link to comment
Share on other sites

I tried using the simple matrix_field.count>0 rule, but it didn't work.

I didn't realize I needed to include the inputfieldset name also. e.g.

matrix_wrapper_fieldset.matrix_field.count>0

EDIT: Nope that didn't fix it. It just stopped showing anything.

For some reason it is not recognizing the count of the matrix items.

Is the data-show-if attribute in the HTML supposed to be escaped? e.g.

data-show-if='meta_zone_1.count>0' data-required-if='meta_zone_1.count>0'

 

Link to comment
Share on other sites

4 hours ago, gornycreative said:

I tried using the simple matrix_field.count>0 rule, but it didn't work.

I didn't realize I needed to include the inputfieldset name also. e.g.

matrix_wrapper_fieldset.matrix_field.count>0

I don't know what the field structure is in your template. It should work fine as described in my previous post. Inputfield names doesn't have much to do with it - you use field names just as you would in any selector. If the selector matches your page in $pages->find($selector) then it should work in the "Show only if page is matched by selector" setting. Seeing screenshots of your template fields and the settings you have chosen for CustomInputfieldDependencies would help.

5 hours ago, gornycreative said:

Is the data-show-if attribute in the HTML supposed to be escaped? e.g.

data-show-if='meta_zone_1.count>0' data-required-if='meta_zone_1.count>0'

That isn't related to this module. It comes from the core show-if and required-if features, so if you are seeing that in your markup it means you are not using the features added by CustomInputfieldDependencies. See the screenshot below.

image.thumb.png.5605d2527599aab3c2a53e06fde83552.png

 

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...