K2 SmartForms: Subforms Style Dependency

If you find yourself in situation where a subform is exhibiting unusual style behavior, check to make sure it’s being instantiated from a K2 SmartForm instead of a View.

Here’s why.

Given:

  • SmartForm “A” contains a Content Control
  • The control displays SmartForm “B”, containing a grid
  • Double-clicking on a row in the grid will open SmartForm “C” as a subform.

Solve: SmartForm “C” exhibits unusual CSS behavior — in our case, the form colors were completely off, and urgently required correction.

I spent six hours chasing down what I thought was some poor manipulation of the style sheet.

The resolution actually had nothing to do with CSS directly. The actual problem was in the chain of events that led up to SmartForm “C” being launched.

Reviewing our “givens,” we’re reminded that SmartForm “A” contains a Content Control that displays SmartForm “B”. Well, that was my assumption. In reality, SmartForm “B” was actually only a SmartForm View, being displayed by its URL.

So our “givens” now look like this:

  • SmartForm “A” contains a Content Control
  • The control displays SmartForm View “B”, containing a grid
  • Double-clicking on the grid will open SmartForm “C” as a subform.

Why should that matter? It matters because SmartForms have appearance properties that Views do not. Themes and other style instructions are assigned at the form level, not in views.

So when SmartForm “C” was launched from SmartForm View “B”, there was no style information to inform SmartForm “C” — which seems a little counter-intuitive, because SmartForm “C” is a SmartForm and has a Theme and other style information assigned to it.

Yet once SmartForm View “B” was enveloped within an actual SmartForm and pointed at a specific Theme, SmartForm “C” was launched as a subform without any further complication. The weird style display was gone.

These circumstances lead me to believe that the Form-Subform relationship includes certain style information as a dependency for the subform.

Given the expense of the lesson (SIX HOURS!), I feel this is worth repeating: If you find yourself in situation where a subform is exhibiting unusual style behavior, check to make sure it’s being instantiated from a K2 SmartForm instead of a View.