7

Is it possible to deploy to cloud a matrix entry form and when submit button would be clicked and then an operation using entered matrix as argument would be executed? So far I am able to deploy APIFunction[] and FormFunction[] to cloud:

    CloudDeploy[APIFunction[{"x" -> "Number"}, #x^2 &], Permissions -> "Public"]
    CloudDeploy[FormFunction[{"name" -> "String", "age" -> "Integer"}, 1]]

, but is there a way I could get similar results to FormFunction[], but instead of form, have a matrix input?

1 Answers1

8

If by matrix input you mean a grid of input cells, then I believe you have to make it yourself. Here's an example.

(* Create a list of field names *)
fields = Flatten@Outer[
    "x" <> ToString@# <> ToString@#2 -> "Number" &,
    {1, 2, 3, 4, 5},
    {1, 2, 3}
    ];
fieldNames = First /@ fields;

(* Take a FormObject and create a grid of with the inputs *)
layout[form_] := Grid@Map[form[#, "Control"] &, Partition[fieldNames, 3], {2}]

(* Output function *)
dispMatrix[names_][assoc_] := MatrixForm@Partition[assoc /@ names, 3]

(* Deploy it! *)
CloudDeploy@FormFunction[
  fields,
  dispMatrix[fieldNames],
  "PNG",
  FormLayoutFunction -> layout
  ]

How it looks:

form example

C. E.
  • 70,533
  • 6
  • 140
  • 264