Home Forums Add-ons Flexible Content Field Hiding A Field in Screen Options


Hiding A Field in Screen Options

  • I know there is the ability to hide an entire seciton by unchecking the option under the screen options tab. However I would like to hide a certain field or a set of fields using this method. Is this possible?

    For a better explanation.

    I recently starting using the Pro plugin and am using the Flexible content field for most of my sites now. In Each Flexible content section I have a field titled “Class”. I use this field to pass CSS classes through that I then use to style the site if needed. What I am wanting is to hide this field once I am done with the site and send it off to the client.

    If I or someone every really needs to change this it should be easy to just click screen options and check to show it again. I am up to other ideas that people have but this is what I am looking for.

  • I will go ahead and answer my own question.

    Instead of adding to screen options I just added a new Boolean field to a theme settings page called “Hide Show Settings”.

    I then run the following code

    //hide show classes fields
    function dd_acf_admin_head() {
    	if( get_field('hide_show_classes', 'options') ) { ?>
    			.acf-flexible-content div[data-name="class"] {
        		display: none;
    	<?php }
    add_action('acf/input/admin_head', 'dd_acf_admin_head');

    This accomplishes my goal of hiding this field but not actually removing it. As its still easy to turn on if needed.

  • To answer the first question, no, there isn’t a way to do this.

    As far as you’re solution, fields that are hidden with conditional logic are not submitted, or at least that is the way it was operating. If you show the fields and then change the values and then hide the fields again before submitting the page the values will not be updated.

    If you find this is not the case please let me know because I’ve missed this change.

    You might want to look at tabs or using a separate group for the fields you want to hide.

  • Hmmm, Did you see my solution above?

    The process is use the fields while I am developing the site. Once it is time to hand off the site to the client I go into my Theme Settings page that has a couple of basic fields and I check mark the “Hide Class Fields” box.

    This simply adds a little bit of css to the head of my admin on pages with acf fields and hides those fields with display none. If this would prevent those fields from saving it doesn’t really matter because they are already saved.

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Hiding A Field in Screen Options’ is closed to new replies.