• Resolved cckarman

    (@cckarman)


    I am looking your calculated fields form in a website with bread-recipes. General setup is the same, but depending on the recipe I want to use different (ingredient) fields. I use the following code to set values for the individual ingredients. What would be your advise if I wanted, for example, omit/hide fieldname5 from the form?

    Thanks,
    Chris

    <script>
    cpcff_default = { 1 : {} };
    cpcff_default[1][ ‘fieldname6’ ] = 13; //aantal broden
    cpcff_default[1][ ‘fieldname10’ ] = 80; //deeggewicht
    cpcff_default[1][ ‘fieldname13’ ] = 63; //hydratatie
    cpcff_default[1][ ‘fieldname3’ ] = 0; //bloem
    cpcff_default[1][ ‘fieldname5’ ] = 0; //water
    cpcff_default[1][ ‘fieldname7’ ] = 0; //zout
    </script>

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @cckarman

    There are different alternatives:

    * you can define it as dependent on another field in the form. More information about dependencies by reading the following post in the plugin’s blog:

    https://cff.dwbooster.com/blog/2020/03/01/dependencies/

    * Or you can assign the class name hide to the field. The class names are assigned to the fields through their attributes: “Add CSS Layout Keywords.”.

    Best regards.

    Thread Starter cckarman

    (@cckarman)

    Many thanks for your prompt reply! I will go and try the dependencies, need it anyway for some other options.

    I have been trying to set the class name hide to the field, it felt like the most straightforward option. I know that I can add it during design to the “Add CSS Layout Keywords”, but how would I do that from the script that I am using in my post?

    Thanks,
    Chris

    Plugin Author codepeople

    (@codepeople)

    Hello @cckarman

    You can assign a custom class name to the field, for example field-a, and then you can assign the class name hide to the field by programming with the piece of code similar to:

    jQuery('.field-a').addClass('hide');

    Best regards.

    Thread Starter cckarman

    (@cckarman)

    Thanks. Unfortunately, this seems not to work. I included the jQuery code between the <script> blocks, but it did not work. Do I need to change something in my settings so that it can work with jQuery in an HTML block?

    Best, Chris

    Plugin Author codepeople

    (@codepeople)

    Hello @cckarman

    The code must be executed after the form is generated. Please, edit your code as follows:

    
    <script>
    jQuery(window).on('load', function(){
    jQuery('.field-a').addClass('hide');
    });
    </script>
    

    Best regards.

    Thread Starter cckarman

    (@cckarman)

    Many thanks, works like a charm!

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘hide fields in post’ is closed to new replies.