# How to create Dynamic InputField Grid for matrix variable? [duplicate]

I need to make an InputField Grid change the values of a matrix variable without creating a ton of dummy variables. Minimal example follows as the actual matrix is much larger. This will be used in a UI.

m = {{1, 2}, {3, 4}};


However, the InputFields are not linked to the values of m when referenced with Indexed. The Grid that is produced has empty InputFields even though m has values.

Grid@
Table[InputField[Dynamic[Indexed[m, {r, c}]], Number, FieldSize -> Tiny],
Evaluate[Sequence @@ Transpose[{{r, c}, Dimensions[m]}]]]


When entering values into the InputFields they simply disappear and have no effect on m. m stays with its original values.

Dynamic@m


I next tried to Part instead of Indexed which led to errors and still the values that are entered disappear.

Grid@
Table[InputField[Dynamic[m[[r, c]]], Number, FieldSize -> Tiny],
Evaluate[Sequence @@ Transpose[{{r, c}, Dimensions[m]}]]]


How do I create an InputField Grid linked to a matrix variable? Other control combinations are welcome. The objective is a GUI to edit the matrix such that the edited matrix can be extracted and used.

## marked as duplicate by m_goldberg, Community♦Mar 3 '17 at 1:08

• @m_goldberg Arrrhhhh!! The dreaded With. That has something to do with the hold attributes of both Table and Dynamic interacting, correct? – Edmund Mar 3 '17 at 0:55