Is there a way to have the same field in an array when posting the data? Since I need the tabs in my component to be generated dynamically depending on the querys output, I can't enter them specifically into that file.


<fieldset name="myset"
    <field name="language" type="language" class="hidden" ...>
    <field name="sometext" type="text" ...>


foreach ($langs as $lang)
    /* html */
    $this->form->setFieldAttribute('language', 'default', $lang['name']);
    echo $this->form->renderFieldSet('myset');
    /* html */

would result in say this:

| English | German | French |

with a language and text field on each tab. The problem here is that when posting it just posts the last state, that would be the contents of 'French'. So is there a way to fix this and make joomla send an array or any better solutions to this issue?

Furthermore, is there a way to say Joomla to put that data into a stdObject because anything in that fieldset is related?

2 Answers 2


Multiple fields with same name

multiple="true" means that your one field can have multiple values, not that you can have multiple fields with same name.

You have to create custom form field to get multiple textareas or selects with same name.

Since you only have to add [] to end of fields name, extend JFormFieldTextarea and JFormFieldList. Then you only have to copy-paste existing getInput functions and add [] after $this->name.

These classes are located at libraries/joomla/form/fields, files list.php and textarea.php.


Only way you can group related data is to add <fieldset></fieldset> into <fields></fields>

Example from Joomla! core com_content article.xml:

<fields name="attribs" label="COM_CONTENT_ATTRIBS_FIELDSET_LABEL">
  <fieldset name="basic" label="COM_CONTENT_ATTRIBS_FIELDSET_LABEL">
      <option value="">JGLOBAL_USE_GLOBAL</option>
      <option value="1">JSHOW</option>
      <option value="0">JHIDE</option>

Now, the output would be.

<select id="jform_attribs_show_title" name="jform[attribs][show_title]" class="chzn-color chzn-done" style="display: none;">
  <option value="" selected="selected">Use Global</option>
  <option value="1">Show</option>
  <option value="0">Hide</option>

All fields in this fieldset will be in jform[attribs]. <fields> attribute name would be array key.

In the end you will end up with something like this.

<fields name="grouped">
  <fieldset name="myset"
      <field name="language" type="mycustomlanguage" class="hidden" ...>
      <field name="sometext" type="mycustomtext" ...>

Add multiple="true" in field xml

<field name="language" type="language" class="hidden" multiple="true" ...>

  • Well, that works with language but not with text and textarea.
    – Vic
    Mar 24, 2015 at 6:21
  • textarea can not have multiple values. But still you need it, you can put [] in name. like name="sometext[]" . But I am not sure that it will work or not.
    – Gaurav
    Mar 24, 2015 at 6:32
  • the name resulting would be jform[sometext[]], must be jform[sometext][]
    – Vic
    Mar 24, 2015 at 6:38
  • Then it won't work.
    – Gaurav
    Mar 24, 2015 at 6:46

Your Answer

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

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