Custom styling on individual fabrikSubGroup within repeating group of tab

chris.paschen

Chris Paschen
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.
 
@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)
 
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 ?>">​
 
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
 
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).
 
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
 
Revisiting this issue again.
We do need to create a custom 'view' for this group.
It is a repeating group; however, all the content is just read-only - nothing is being saved.

If this were a list or a detail or form I would understand to just create the tmpl and then assign it within the layout config of that list/detail/form.
However, I need to have a unique layout specifically for this one group.
I want to control exactly what appears on that group listing (i.e. data for the individual rows) as well as the layout/style.
However, I'm not seeing any way to assign a specific 'template' to a specific group.

Is that even possible?
Am I just missing the obvious?
 
No, you aren't missing anything, there isn't a way to do that built-in.

You'll have to down and dirty, clone a template, and code it up. In default.php test for the group ID you want to handle, call your own default_foo.php template, and handle it yourself.

And I'm afraid the templates aren't very friendly.

-- hugh
 
I was afraid of that.

Is there then a way to easily override the output of an individual element (specifically to take a 'field' that has a '1' or a '0' and instead display an icon (x or check)?)

[And at some point I'm expecting you to tell me to just go write a custom component ... because I'm pushing Fabrik beyond it's limits :) ]
 
In general, most elements have layouts, in their plugin folders. You can override those layouts on a site template, Fabrik template or per-element basis (see wiki).

In your case, in form view you could override ...

./plugins/fabrik_element/field/layouts/fabrik-element-field-form.php

... by copying it to ...

./components/com_fabrik/views/form/tmpl/bootstrap/layouts/element/yourtable___yourelement

... to override it for that one element. Obviously change yourtable___yourelement to your element's full name.

Unfortunately, there isn't a layout file for details view, as we don't "do" anything to the output, we just use the value ... but I could easily add one that just renders the value, simply as something that people could override if they want. Let me know if you want that.

-- hugh
 
Well, I need to control it in the details view.

However, I think there might be an easier way to address this...

I just need a 'list' of data that I could easily create with php/sql (no actions are needed on the data).
Is there any easy way to create a display-only query in a group? (other than creating my own element plugin - or just using a plugin from RegularLabs to just insert code directly into a group intro?)
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top