michaeluno / admin-page-framework

Facilitates WordPress plugin and theme development.
http://admin-page-framework.michaeluno.jp/
Other
337 stars 71 forks source link

Section Toggle #162

Closed LoreleiAurora closed 9 years ago

LoreleiAurora commented 9 years ago

Hi Michael,

Is there any way to have a sections visibility toggled by a select menu? i.e. I have a select field in a metabox and 2 sections (should be hidden by default) If sales option is set > show sales section + hide lettings section If lettings option is set > show lettings section + hide sales section

Sorry if im just missing something obvious. Sofia xXx

michaeluno commented 9 years ago

Try the revealer custom field type and specify the selector of the section container element (you need to check the HTML source to find the element selector). It's talked about here.

Though the section by default won't be hidden until the script gets loaded so you may notice the section output while the browser is loading, which may appear like a kind of flickering effect. In order to avoid this, maybe the hidden argument for sections need to be introduced. If you need that, post a new suggestion about it.

If you want to talk about implementing dynamic conditional visibility possibly suggested here, feel free to suggest the syntax and how the options should be set.

michaeluno commented 9 years ago

I've added an example in v3.3.1. Navigate to Dashboard -> Admin Page Framework -> Custom Field Types -> Revealer. The bottommost select item can switch visibility of sections. Also v3.3.1 includes the hidden argument for sections which can be used to avoid the issue mentioned above that the section output gets displayed while the page is loading.