Jump to content

"show field if only this" Problem (Solved)


EyeDentify
 Share

Recommended Posts

Hello There fellow PW gurus.

I am trying to make a field show as open only if the field is filled out with at string.
for example: "my_styles.css" and stay hidden if the field is empty.

The field in question is of type "text" if that helps.

And i put in the "show this field only if"
css_filename!=''

because the field name is "css_filename"

But no mather what the field is closed because i have choosen it as "closed" as default.

What am i doing wrong?

i am running PW 3.0.83 Dev.
 

screenshot_show_field_if_part1.png

screenshot_show_field_if_part2.png

Link to comment
Share on other sites

18 minutes ago, Juergen said:

A typical usecase for https://modules.processwire.com/modules/custom-inputfield-dependencies/

screenshot-www.juergen-kern.at-2017-11-13-12-49-50.png.b4212b7d2697c3b65f1b7cc85fdfe197.png

The code inside the textarea field is not testet but I guess it works.

Another possibility would be to add a hook to "Inputfield::render", but with this module you can use it on all inputfields on your site and I think you will probably need something similar in the future.

With the default "show only if" condition you check for a value of another field and not the same field. So the condition depends on a field different than the css_filename field. Fe show css_filename field only if field XY is not empty.

Thank you @Juergen for this answer.
Now i understand what i did wrong.

I did not know that i could not test the field itself that i wanted to change visibility on.
But your answer explains it well.

I Thought i was going crazy there for a minute :)

 

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

×
×
  • Create New...