On my detail page edit.php I have a list of records. The user can select records by a checkbox and the number of selected records is not fixed, I mean it can be one record, but also one time 5 or 11 records.

The total list of records can be 3 or 500 records or even more, so I don't want to put this in the form and submit the whole bunch! I looks not an good idea to me.

I try give an idea how I see it like an array

        "rec1": {
                    "value1": "some data"
                    "value2": "some data"
                    "value3": "some data"
                    "value4": "some data"
        "recn": {
                    "value1": "some data"
                    "value2": "some data"
                    "value3": "some data"
                    "value4": "some data"

I have to save these value's as record in certain table. This I have this principle working, simply with the form fields one-value and different number of records.

Now I want to extend this with more data. My question is, I'm looking for an tutorial or example of how do I:

  1. If I press the "Save" button, how can I submit these record value's to the controller to save them?

  2. At the controller site how to pick up the records and extract values to save again?

What is the best way how to do that? application/Json or application/XML or application/x-www-form-urlencoded? Till now I don't when or why is the one or another used?

I hope that someone can help me further and help me out so that I at least get an idea how to solve this.

Best Regards,


  • Questions that seek a complete tutorial are often Too Broad / Need More Focus on Stack Exchange sites. SE communities are comprised of volunteers entirely. As matter of respect toward volunteers (who are likely to be paid for their everyday Joomla work), we ask that all question askers exhaustively research and try to self-solve before posting a question. It has been my experience that more times than not, when a question is asking for "too much", the answers are vague/low-quality or the most capable volunteers will simply avoid the question. Commented Jun 8, 2020 at 23:45
  • I always wish for new members to have a great first experience, so this is not a "go away". Please edit to include some of the Joomla documentation and tutorials and other webpages that you have studied before asking. Please show us how far you got with coding a solution. If this task is simply beyond your current range of abilities, then it is probably more appropriate that you actually pay for a Joomla developer to do the work for you (and perhaps you can build into the contract that they explain their development once complete). Regardless of all this, welcome to JSE. Take the tour. Commented Jun 8, 2020 at 23:48
  • As for technical advice. When you have a form that is submitting an indeterminate number of "rows", you should avoid declaring keys that are "{string}{number}". Instead, you should use array syntax in your form -- e.g. <input name="rec[]" ...> then all subsequent tasks will be cleaner and easier to process. Commented Jun 8, 2020 at 23:54
  • What I have now is: four hidden fields (value1 .... value4) in the form. These are comma separated filled with the the field record value's. After a submit I pick this up at the controller -serversided-, create an array of it and save it to the dabase. But I'm doubting if this the way how to do this. Till now I have not found in the Joomla docs but is very specific Commented Jun 9, 2020 at 12:50

2 Answers 2


I haven't verified what's below, but I think it should work.

I suggest you have a look at the Joomla Content Articles form, where you can select multiple articles via the checkboxes and then perform a batch operation, such as publishing / unpublishing all these. In particular look at administrator/components/com_content/views/articles/tmpl/default.php.

Another example is in https://docs.joomla.org/J3.x:Developing_an_MVC_Component/Adding_backend_actions in the admin/views/helloworlds/tmpl/default.php code.

Basically you want to use something like what is in the com_content articles layout file:

 <?php echo JHtml::_('grid.id', $i, $item->id); ?>

for each of the records, which will output a checkbox with the html "name" attribute set to "cid[]" which will cause the ids to be sent in the http post as an array, so you can easily get these into a php array in your controller.

See https://api.joomla.org/cms-3/classes/JHtmlGrid.html#method_id for the API details (including eg how you can change the "cid" name).

Also include a hidden field

<input type="hidden" name="boxchecked" value="0" />

which will give you the number of records checked.

  • Hi Robbie, Thanks. I've been through the articles and I have been watching that video's and some others. Not all on this moment. I have bought the book "LEARNING JOOMLA3 EXTENSION DEVELOPMENT" and try to find out how the frameworks work. I understand what you are saying there and maybe I can bring this to the detail.php. I have to look at because I have implemented the whole with jQuery because I have also add a filter bar with Ajax so that you can filter persons by first and or last name etc. I had first made a custom field but because I have filter bar with Ajax I have chosen later jQuery. Commented Jun 10, 2020 at 19:22
  • Robbie, may I ask this. I have seen video 20 about Ajax I have implemted this, few weeks ago at the backend (not frontend) There you have: `return { minlat: latlngMapbounds[1], maxlat: latlngMapbounds[3], minlng: latlngMapbounds[0], maxlng: latlngMapbounds[2] }' In the Ajax call you have associative array: 'data: { [token]: "1", task: "mapsearch", format: "json", mapBounds: mapBounds },' The mapBounds param. is the array which is picked in the model. My Question is: can I do such thing at the save of the details page (edit.php)? Commented Jun 14, 2020 at 9:59
  • I wouldn't recommend doing an ajax call in conjunction with the save in the edit.php form (which is going to result in an http post request with the form data). You could theoretically send the ajax request just before the post, but that could cause race conditions on the server (handling 2 requests accessing similar data items) and you've no way of reporting back to the user errors associated with the ajax call (as the page context on the browser will disappear with the http post). Much better to put all the data into the http post request, and have it fired from the save button. Commented Jun 14, 2020 at 12:18
  • Hi Robbie, Thanks again. I don't want do an Ajax call at the time of saving at edit.php. What I mean is in you're Ajax part link, there you explain an Ajax call with passing the array mapBounds: mapBounds in the signature as a parameter. My question: is passing like an array as mapBounds also possible when I press the save button of the edit.php, so that i can pick the array up at the controller save function? And if so, I'm looking for an example. (BTW. I have save at the controller working) Commented Jun 15, 2020 at 9:59
  • No, you don't pass them like the Ajax call. If you're using the Save and http post then in your layout file iterate through the list of records, outputting them as I described in the answer using JHtml::_('grid.id', $i, $item->id); Then when you press Save if you put your browser's devtools on you should see the cid array associated with the records you select being sent in the data to the server. It's similar to the com_content form which has all the articles and you check the checkbox of the articles you want to process (eg publish/unpublish). Commented Jun 15, 2020 at 18:00

I think I understand the 'misunderstandnis' and I will try to make it more clear.

I have edit.php with list of records (it is more ore less an admin view of an another table). The user can select 1 or more 'records' by a checkbox and add some additional data to this record. This is data for a link table and not for the admin view I mention here before

I have made a filter bar, so the user can filter the list of records, which I have created with Ajax.

Add the moment the user decide to press the 'save' button, not all records are on the moment on the form because of the filter. On this moment I keep track of the selected records by putting the record id in a hidden field without the additional data, only to get the principle working!

But now the case I think were it turns around: So at the client side, before the user press the save button, I must have 'secured' somewhere the selected record id with the additional data!

Now, I think, the only way to do this is, to put it in an hidden field like this and I will try this:

'add_array' => string '{ "add_Array0":{"key0":"value0","key1":"value1","key2":"value2","key3":"value3"}, "add_Array1":{"key0":"value0","key1":"value1","key2":"value2","key3":"value3"} "add_Arrayn":{"key0":"value0","key1":"value1","key2":"value2","key3":"value3"}}'

With <?php echo JHtml::_('grid.id', $i, $item->id); ?> I'm to 'late', because it is server sided and what I mention, not all records are on the form on the moment of pressing the save button of the details page (edit.php).

(Besides this: the functionality around selecting, deselecting records which mean maintaining the hidden field with ONLY record id, I have working. Also saving it in the database with insert new records, update records, remove records. That's not the issue.)

I hope that I have it made more clear what I'm working on. The reason why I'm asking it here is that I'm curious if there is an 'mechanism' in Joomla or a smarter way to solve this, because I can't believe that I'm the first one with this issue.

And I'm also curious, it is the backend, but can it be an security issue to put the data on this way in the hidden field?

Thanks in advance,


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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