• I utilize Bootstrap CSS to layout the various fields of the forms I create with Contact Form 7 to achieve fairly compact forms when viewed on wide screen monitors. I also utilize your wonderful plugin to conditionally display fields within my forms.

    Would it be possible to create an option for the group operator which would cause the viewable fields to be displayed in Flex mode containers instead of Block mode containers?

    The inline styling which forces the display mode between none and block to hide and reveal conditional fields cannot be overridden by CSS. A simply option on a conditional group by conditional group basis could support the more creative layout of fields

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Jules Colle

    (@jules-colle)

    If you add a style rule of display:flex to a group, it should persist.

    Something like this should work:

    [text t]
    [group flex-group]
    <div>1</div>
    <div>2</div>
    [/group]
    <style>[data-id="flex-group"] { display: flex; justify-content:space-between; }</style>

    (note that you can add the style to your stylesheet, it doesn’t need to be inline.)

    See it in action here: https://conditional-fields-cf7.bdwm.be/form-tester/?hash=486d822b947e58d199a1acdb6f10e49a (link might expire after 10 days)

    Thread Starter Benedict Popelar

    (@bpopelar)

    Hi Jules,

    Thank you for your timely response.

    I’ve tried your suggestion (added it to the stylesheet) and it does not override the inline HTML style statement that the js uses to toggles the display mode between none and block mode.

    The display of the “Physical Location:…” block of fields (located in the middle of section 4 of the form) is controlled by the “Group is Meeting” radio buttons in section 3 of the form below:

    https://www.scws-al-anon.org/new-al-anon-group-registration-form/

    Ben

    Plugin Author Jules Colle

    (@jules-colle)

    hmmm.. interesting.. And does it work if you add the styles inline in the form between <style> tags?

    Thread Starter Benedict Popelar

    (@bpopelar)

    No it won’t.

    The styles defined as HTML attributes have a higher precedent than any other styles (defined either inline between <style> tags or included in a stylesheet). The only way to override the HTML style attributes is to add the !important modifier to the lower priority style definitions. Doing so forces the display attribute to always defined as flex and consequently the toggling of the display attribute by the js has no effect (and the conditional fields are always displayed).

    Plugin Author Jules Colle

    (@jules-colle)

    I’m not sure why it works in the form tester then. The fields are shown via the jQuery function $.show() which takes into account the initial display type of the group it’s making visible. I guess that if you declare the style before you are rendering the html page it will work.

    Thread Starter Benedict Popelar

    (@bpopelar)

    I went back and switched to defining the style inline with <style> tags after the conditional block code and it is working as you described.

    Although the inline style tags have a slightly higher precedent than the stylesheets defined before it (sorry the brain is a little foggy – order matters), the slightly highed precedent shouldn’t matter; however, it appears to make a difference as the jQuery function $.show() is clearly deciding to add the display:block style to the HTML element when the stylesheet approach is used (but not when the inline style tag approach is used).

    Not sure why that is the case, but thanks for the help!

    Ben

    Plugin Author Jules Colle

    (@jules-colle)

    I guess jQuery is aware of the styles because they are available directly in the DOM. But not 100% sure about this. Anyhow, I’m glad you found a work-around for this issue.

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

The topic ‘Conditional Group Option to Allow Flex Display’ is closed to new replies.