views:

202

answers:

1

Hi, I need to create a form in CakePHP to allow users enter data(numbers) into the cells shown on the table below. The input screen needs look like the table shown below. The users should be able to select any cell they want to enter/update the value, then type in the value, click submit and submit the value/s. Each "Metric section (e.g. Metric A, Metric B..)" will have a submit button so the users can edit/update each section on the table.

 ___________________________ ____________________
|___     ___|___2006_______|__2007____|___2008___|
|_METRIC A__|______________|__________|__________|
| item A1   |          1   |    5     |    7     |
| item A2   |         15   |   18     |   21     |
| item A3   |          3   |    6     |   11     | 
| item A4   |          1   |    1     |    3     |
|___________|______________|__________|__________|
|_METRIC B__|______________|__________|__________|
| item B1   |         12   |   18     |   31     |
| item B2   |          1   |    4     |    6     | 
| item B3   |          0   |    0     |    2     |
--------------------------------------------------

As you can see each metric section is a two dimensional table. So I would like to capture the input data in a 2D array. Currently I have successfully created the display for the data (which was much easier). I simply created an array of metrics, which is an array of 2D arrays. Then I passed that array of 2D arrays to the view file to display the table.

I am kind of lost on how to get the user input for this table. Any one had any similar experiences? Any suggestion will be greatly helpful to me.

+1  A: 

You might want to start be researching some Javascript grid solutions with editing capabilities. Ext's Grid comes to mind, but there will most definitely be alternatives for your JavaScript framework of choice (eg. jQuery). This will handle all of the onclick goodness on the client side leaving you to implement an AJAX action that the form can submit data at. There it is up to you to determine which models you update with each part of the data.

deizel
Thank you. Javascript grids was something I haven't thought about yet. Will have a look at it to see if it helps. By the way I may have found a way get input into a 2D array.$form->input('x', array('value'=>$dataRow[$n], 'name'=> 'data[multi]['.$m.']['.$n.']' ))still working on it.
Vicer