Forum OpenACS Development: Forms X matrix input structure
I have been struggling for 5 long days trying to figure a way out to create a form to handle the creation of several items at once.
I thought the best way to go would be that the formulary might manage the creation of items using a matrix structure.
Furthermore, I would like the form having the ability to load data at the moment the user selects the item's code in the first field of the row.
Moreover the scenario would be that for every row the user selects the first value the rest of the fields might be filled automatically. The after he chooses as many items (rows) he wants, he could hit submit and all the items would be sent to the database
Here it is the link to see the interface
I already tried some ajax grid samples such as http://www.sigmawidgets.com/products/sigma_grid2/ but mixing it with TCL turns out into a nightmare.
Does anyone have an enlightening idea?
field1.0 field2.0 field3.0
field1.1 field2.1 field3.1
And automatically append new rows with the row number appended with a dot to the field name.
Then you can use
You can still use ad_form for the form processing blocks but you'll need to loop over all the arrays to get each row and the process them that way.
There isn't any openacs code specifically that you need to fill fields based on the value of a previous field.
Try this google search
How would I load up the other fields then?
For example, let's supose the user selects field1.0.
The form must be refreshed and the fields must be automatically filled. "Every row respectively"
field2.0 field3.0 field4.0 field5.0
I guess i have the knowledge about the pieces, however I still don't have a picture of "how" to accomplish the task.
To send data from your form to the db (without refreshing), execute an AJAX request with your favourite library to a Tcl file that saves the data to the db.
Don't use "onChange", instead use an Event Listener (google addEventListener).
Hope that helps.
Thank you guys for the feedback.
It helped a lot. I don't know how but it works! (sharing and writting about difficulties surprisingly open the mind. It makes you to look outsite the box.
I saw openacs lacks json interfaces. Its API is very poor. Isn't?
Am I correct?
You might be interested in the qf_ form API. It's made for scenarios like the one you have, with multiple arrays, dynamically declared forms and fields etc: