# StandardForm in Cloud FormFunctions

Cross posted on community.wolfram.com

### Example

choices = {
"label 1"                     -> 1
, Column[{"label", 2}]         -> 2
, Framed[3]                    -> 3
, HoldForm @ Sum[i, {i, 0, ∞}] -> 4
};

CloudDeploy @ FormFunction[
{ "a" -> <|
"Interpreter" -> choices
, "Control" -> (RadioButtonBar[##, Appearance -> "Vertical"] &)|>
}
]


So by default StandardForm is not supported (though e.g. Column is).

### My attempts to fix it

• I tried to force "HTMLCloudCDF" as an export form for those elements:

 ...
"Interpreter" -> MapAt[ExportForm[#, "HTMLCloudCDF"] &, choices, {All, 1}]
...


But it is not supported.

• At the end I am using: ExportForm[#, "SVG"] & but it makes fonts inconsistent with the rest of the form and selected item's label gets an ugly red frame if it is an image:

### Question

How to use arbitrary expressions in form functions layout? Is there a better way than SVG? Shouldn't it work out of the box?

### Related

Wolfram Cloud deployment guidelines

## 2 Answers

What about doing the following thing.

(1) In a text cell (Ctrl-7) just write the mathematics, that is Ctrl-( to open inline math, type the formula and Ctrl-) to close the inline math.

(2) Shift-Ctrl-E to Show Expression and copy the expression. Example below.

math = Cell[
TextData[Cell[
BoxData[FormBox[
RowBox[{RowBox[{"F", "(", "x", ")"}], "=",
RowBox[{SubsuperscriptBox["\[Integral]",
RowBox[{"-", "\[Infinity]"}], "x"],
RowBox[{RowBox[{"f", "(", "\[Tau]", ")"}],
RowBox[{"\[DifferentialD]", "\[Tau]"}]}]}]}],
TraditionalForm]], FormatType -> "TraditionalForm"]], "Text"]


(3) Use combination of EmbeddedHTML[] and ExportString[] with MathML format. Example below.

mathml = EmbeddedHTML[ExportString[math, "MathML"]]


(4) Using this I produced the following form.

FormFunction[
{Style["Form 1", "Title"],
"Describtion of the form here.",
"x" -> <|"Interpreter" -> {"A" -> 1, mathml -> 2},
"Control" -> (RadioButtonBar[##, Appearance -> "Vertical"] &),
"Label" -> "Select choice"|>},
Identity,
PageTheme -> "Blue"
]


The code above gives the following result.

This is not ideal but at least it does not have the frame around it and fonts seem to be consistent.

This answer is based on the help that I got from @b3m2a1 and @Kuba (he pointed me the this question).

• +1 I will definitely use it but it won't help with more than math content, right? So e.g. Framed[1] will still be problematic. Either way, thanks for help. – Kuba Aug 20 '17 at 21:56

To an address your comment on Michal's post, we can actually implement the Framed in CSS and use that in the FormFunction, using the styledXMLExport from this answer:

$xml = XMLElement[ "p", {}, { XMLElement["framed", {}, {"1"} ] } ];$style =
{
"framed" ->
{
"border" -> "solid 1px black",
"display" -> "inline-block",
"padding" -> "5px"
}
};

fo =
FormFunction[
{
styledXMLExport[$xml,$style]
}
];
HTTPHandlingStartWebServer[fo];
"http://localhost:7000" // SystemOpen
`

Of course, just because we can doesn't mean we should have to. WRI is clearly dropping the ball here.

• I know I can (124015), but I still will be left with out general solution and uncertainty about what works and what does not. Not to mention that I'd have to manually translate all options. :( – Kuba Aug 21 '17 at 8:23
• @Kuba when I have time I'll pick through the HTML export context because my guess is a lot of this is cooked in. Or maybe we can do an HTML export sans links or something and that'll be fast enough. – b3m2a1 Aug 21 '17 at 9:52
• Forms are typeset cloud side afaic so relevant code may not be available locally. – Kuba Aug 22 '17 at 7:00
• @Kuba Yeah I was gonna do the compilation on the deployment side. But I looked at it and there's no good support for things like Framed so ah well. – b3m2a1 Aug 22 '17 at 7:34