1

I have try to define a array in media field name in joomla xml file.but it doesn't work. here what I want

<field name="s1img[]" label="Image 1" type="media" directory="Images" />      
<field name="imgSetting[]" type="text" default="" label="Image Setting" description="" size="60"/>

<field name="s1img[]" label="Image 2" type="media" directory="Images" />
<field name="imgSetting[]" type="text" default="" label="Image Setting" description="" size="60"/>

<field name="s1img[]" label="Image 3" type="media" directory="Images" />
<field name="imgSetting[]" type="text" default="" label="Image Setting" description="" size="60"/>

When i used this code it looks like this. Only Show Last field

How to fix this..?

2

Sadly, this is not how it works in Joomla. Your fields have to have unique names.

If you only have these 3 fields, I would suggest to name your fields s1img_1, imgSetting_1, s1img_2, ... This will make things easier to save into database as well.

If the number of fields will by dynamic, you should consider using the new subform field type. This allows you to build repeatable form fields.

  • if there any solution for this? i want to this images path in one array. i'm using it now these all values in one array.. – Backslash Sep 27 '16 at 12:49
  • Why one array? You can't save arrays directly into database either. But you could override your models save and load functions to save and load all 3 values into/from one database field. – fruppel Sep 27 '16 at 13:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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