1
$\begingroup$

There are two wrong code like this:

The first problem is I want to put the red string to Title.

CloudDeploy[
 FormFunction[{"x" -> "Integer"}, #x! &, 
  AppearanceRules -> <|
    "Title" -> StringTemplate["This is a ``.", 
       InsertionFunction -> (ToString[#, TraditionalForm] &)
      ][ Style["RED", Red]]
  |>], 
"myform", Permissions -> "Public"]

enter image description here

The second problem is I want to put the Hyperlink to Description.

CloudDeploy[
 FormFunction[{"x" -> "Integer"}, #x! &, 
  AppearanceRules -> <|
    "Title" -> StringTemplate["This is a ``", 
       InsertionFunction -> (ToString[#, TraditionalForm] &)
    ][ Hyperlink["Sample Image","http://pan.baidu.com/s/1xCeUq"]]
  |>
], "myform", Permissions -> "Public"]

enter image description here

So is this a bug or are there some method to realize it?

$\endgroup$

1 Answer 1

2
$\begingroup$

The answer is, don't convert everything to string.

It seems that Cloud can't work with String representation of Boxes so let's use real expression instead:

CloudDeploy[
 FormFunction[
  {"x" -> "Integer"}, #x! &,
  AppearanceRules -> <|
    "Title" -> Row[{"This is a", Spacer@1, Style["RED", Red], "."}]
    |>
  ],
 "myform",
 Permissions -> "Public"]

enter image description here

Notice that I have put there Spacer[1] before RED, that's because Whitespaces are trimmed in the Row, I don't know why...

The same solution works for you second problem:

"Title" ->
 Row[{"This is a", Spacer@1, 
   Hyperlink["Sample Image", "http://pan.baidu.com/s/1xCeUq"], "."}]

enter image description here

$\endgroup$
4
  • $\begingroup$ yeah,Thanks for you help,and do you think this is a bug of mathemtaica? $\endgroup$
    – yode
    Dec 5, 2015 at 18:04
  • $\begingroup$ The same thing that we cannot inupt carriage return by a "\n".Do you give a method? $\endgroup$
    – yode
    Dec 5, 2015 at 19:06
  • 1
    $\begingroup$ @yode The same, don't use strings. Here, a Column might be of use. $\endgroup$
    – Kuba
    Dec 5, 2015 at 19:09
  • $\begingroup$ reference.wolfram.com/language/ref/EmbeddedHTML.html may help here. $\endgroup$
    – Bill White
    Jul 19, 2019 at 17:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.