1. Fabrik 3.7 is now available. This version contains critical security updates, please update as soon as possible. Please remember to backup your site before updating, we also recommend testing your updates on development sites if possible.
  2. We had to restore the site around midday (CST) on Wed 7/26 from a backup approximately 8 hours old. So a few posts in the forums were lost. You may want to check to see if you need to re-post anything.

Custom styling on individual fabrikSubGroup within repeating group of tab

Discussion in 'Professional Support' started by chris.paschen, Sep 12, 2017.

  1. chris.paschen

    chris.paschen Chris Paschen

    Level: Professional
    We've got a form that has several groups displayed in tabs.

    One of the tabs has repeating groups.

    Within each group I have a radio button that sets a 'status' of that specific group.
    There are 3 different 'settings' for that status.

    I need to set the background color for the group based on the setting of that button.

    In looking at the page it appears that there are divs for each repeating set within the group with the style of "fabrikSubGroup"; however, I'm not seeing any other unique identifier on the individual subgroup divs.

    Is there any way I can make fabrik add unique identifiers to those sub-groups based on the status of that one radio button?
    Can I build a 'subGroup' template that would be used for this?

    I'm not completely sure where to look or start with this.

    Any pointers or directions to existing docs would be appreciated.
     
  2. chris.paschen

    chris.paschen Chris Paschen

    Level: Professional
    @startpoint provided some code for customizing a subgroup template (see below); however, I'm not sure where to create a sub-group template or how to assign it (because it needs to be assigned at the group level, not the form level).

    Can anyone point me to creating a template for a sub-group?
    (I'm not seeing instructions in the wiki or in any other forum posts)
     
  3. chris.paschen

    chris.paschen Chris Paschen

    Level: Professional
    Here's the code that was suggested by @startpoint

    you need to change your subgroup template to add some class based on some value with php.

    if($value =='value'){
    $unique_class == 'unique_class';
    }
    <tr class="fabrikSubGroupElements fabrikSubGroup <?php echo $uniquel_class ?>">​
     
  4. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    Do you need to do this in "live" on the page, so that when the user changes the status, or adds a new group, the styling changes?

    -- hugh
     
  5. chris.paschen

    chris.paschen Chris Paschen

    Level: Professional
    Yes, it would HAVE been needed in a live group; however, after some additional review (and considering the potential complexity of the code) we've re-designed it in a way to NOT use a repeating group.
    So I no longer need this functionality right now.

    HOWEVER, if there is instructions on how to create a template for a group (a sample, where to put it, how to select it), that would be very helpful as I would really like to be able to create custom templates at the group level (I've just not found where to do that yet).
     
  6. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    The repeat group template to use depends on which method you are using for display (div or table), but are fairly obvious to find in the template folder.

    The problem with what you need to do is that you can't do that kind of value dependent styling in the template, if you want it to be "live". The template only builds the initial state of the groups, on the server side, as the page is loaded. Anything being done in the browser, responding to changes made by the user, has to be handled with JavaScript. When you (say) add a new group, we aren't making a call to the server and running the template again, we just copy one of the existing groups from the DOM.

    -- hugh
     

Share This Page