Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Kris Janssen 210 posts 569 karma points c-trib
    Jun 10, 2014 @ 11:00
    Kris Janssen
    0

    Bootstrap style forms and conditionals

    Hi,

    I like to style my contour forms using Bootstrap.

    For the purpose, I often edit the standard views, including Forms.cshtml:

    @foreach (FieldViewModel f in fs.Fields)
                        {
                            bool hidden = f.HasCondition && f.ConditionActionType == FieldConditionActionType.Show;
                            <div class="@f.CssClass" @{if (hidden){<text> style="display: none"</text>}}>
    

    Enphasis on:

    <div class="@f.CssClass" ...
    

    Which I replace (among other things) with:

    <div class="form-group" 
    

    This however, stops conditional fields from working.

    I think it is because @f.CssClass always seems to be set to:

    "contourField fieldcaption fieltypename"

    particularly, removing "contourField" stops conditionals from working.

    Two questions:

    1. Where is CssClass set? I cannot find references to it in any of the standard views. Is it handled by contour code somwhere?
    2. Where is the javascript that handles the conditional formatting (and supposedly looks for contourField)? It is not in contourform.js, right?

    I really would like to understand this better...

    Cheers,

    Kris

  • Dominic Jones 2 posts 22 karma points
    Jun 12, 2014 @ 12:15
    Dominic Jones
    0

    I'm certainly no contour expert, but I can't think of any reason why you can't simply replace your code with: 

    <div class="form-group @f.CssClass" ...

    Which will simply apply both classes - giving you your bootstrap styling and allowing any conditional display control added (presumably by javascript) later on by contour.

  • Kris Janssen 210 posts 569 karma points c-trib
    Jun 12, 2014 @ 12:40
    Kris Janssen
    0

    Hi Dominic,

    That' s true, I eventually did that and it works perfectly.

    Still I' d really like to know more about how things are hooked up in Contour. I really cannot seem to find the bit of js that takes care of the hiding/unhiding :s

Please Sign in or register to post replies

Write your reply to:

Draft