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?


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! *)
  FormLayoutFunction -> layout

How it looks:

form example

  • $\begingroup$ Oh my God, that is incredibly useful. Thank you! $\endgroup$ May 29 '15 at 22:55
  • $\begingroup$ Pickett, If I want to do some calculations over the form fields. How to access those? $\endgroup$
    – Vijay
    Feb 19 '16 at 7:22
  • $\begingroup$ @Vijay You implement your own dispMatrix function that generates whatever result you want to return. $\endgroup$
    – C. E.
    Feb 19 '16 at 10:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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