One of my favorite TV shows in college was "Pimp My Ride." I loved how Xzibit, or X-to-the-Z as I affectionately call him, would come pick up a jalopy of a car, take it to his buddies who would throw unnecessary enhancements on the car and effectively "pimp" the car. Forms are very similar to the cars on "Pimp My Ride": drab and functional. Why have drab and functional forms when you can have some swag in your tabs that isn't a tepid jQuery animation? Today we're going to pimp a Nintex form by creating some novel looking tabs using HTML, CSS, and jQuery.
First, we're going to need a series of panels. These panels will hold the elements we're going to tab through. In this post I'm going to have a parent panel called "Wrapper." Within wrapper I have three panels, "Apple", "Banana", and "Cherry." It should look something like the image below.
Make sure that all of the panels are nested within Wrapper. You can do this by clicking Wrapper. When Wrapper is selected, all of the nested panels should be selected too.
Next thing we need to do is give our tabs some nice CSS classes. In Nintex Forms, you do this via the ribbon in the formatting section.
First, assign wrapper a CSS class of wrapper. Then give apple, banana, cherry the classes of tab apple, tab banana, tab cherry.
What we need to do now is make it so when we toggle through the tabs, that the different panels appear on the top. As is, if we were to toggle, only apple would appear at the top; banana and cherry would be in the middle and bottom of the form respectively. CSS can help take care of this problem.
Add this to the form's CSS.
When you preview the form, depending on how your panels are built, you should only see one panel because they’re all stacked on top of each other due to the CSS. But when I crack open the developer tools, I can see that all of my panels are there and are nested beneath wrapper. This is what we want.
Now that the panels which will contain our content are built and assembled, we need a way to toggle through them. I was inspired by this post and wanted to make the chevrons function as tabs in the form. I did made some minor adjustments however; instead of an unordered list, I wanted to use an ordered list. This way my tabs have numbers on them.
In the space above the wrapper panel, add a rich text control. Edit the rich text control and add this markup:
A few things to note. The first LI has a class of selected. This means that it'll be selected by default when the form knows. Also, when we toggle through the tabs, this class will be assigned to the other LIs. Lastly, I'm using the data-target property. For each LI, the data-target should match the whatever comes after "tab" in the respective tab's CSS class.
Now we have a raw list which we will turn into tabs with CSS. If this were "Pimp My Ride", Xzibit would stare into the camera and make some droll joke right now before wheezing out a THC-laced cough. Since I don't have the comic delivery of X-to-the-Z, let's keep working.
Add these styles to the form's Custom CSS properties.