repeatable - How to get values from this field type ?

I am coding a Free module with a repeatable field.

<field name="star_slides" type="Repeatable" icon="list" description="" label="Edit Your Slides" default="{'main_image':[''],'left_side':[''],'right_side':['']}">

For a normal module parameter, I can get value like this

$test         = $params->get('test');

If I do the same for the repeatable field

$test         = $params->get('star_slides');

I get all the values of the main field - Looks like an array output.

How to do this for a repeatable form field and get value of EACH repetition of the field?

For example, in the above case, my goal is to get the value of the field "main_image" for each repetition. I am thinking use "for each" but not sure how to get through and pull the values of each row, each field - one by one.

2 Answers 2


Since you are getting data from your call and it's an' array you can do a simple (Working out from the idea that you are working on a developer server / system)

echo '<pre>';
echo '</pre>';

This will show you what data you are getting out and you can then check whether it contains your needed data (Which it should.)

You can then use a simple foreach loop to get what you want

foreach($test as $val){
   //Store in another array or do what ever you want with the values

(And if you want the name of the repeated field aswell)

foreach($test as $key => $val){
       //Store in another array or do what ever you want with the values

Or, you should be able to do a simple $test['field'] like a normal array value. Keep in mind you might need to dig a little into the array either by an' additional foreach or making your first foreach start at the secondary array if needed.

  • Edited above answer
    – Star
    Jan 18, 2015 at 0:33
  • 2
    @Star, editing an answer and changing it completely (you left only 3 words from the original answer...) is not the correct way to use JSE. Please comment if needed, or add another answer if you have found a solution.
    – johanpw
    Jan 18, 2015 at 3:37
  • @johanpw - Well - I edited the answer because it would confuse any user just like it did to me. This is a Joomla specific question and my answer was more relevant. Looks like you did not approve my answer which was very close to being complete - By doing so you are NOT DOING ANY GOOD in JSE.
    – Star
    Jan 18, 2015 at 14:44
  • 1
    @Star, your edit should be posted as an answer. If it solves your problem, you can mark it as accepted, if not it might help other users give you a more complete answer. If the answer above is incorrect, you can flag it for moderator attention. I still have a copy of your original edit if you want to post it as an answer.
    – johanpw
    Jan 18, 2015 at 16:13
  • "When I echo the contents on a repeatable joomla fieldset, I get the following result: {"Field1":["/demo/slide1.jpg","/demo/slide2.jpg"],"Field2":["Content 1","Content 2"],"Field 3":["Content 3","Content 4"]} Now the above result is obtained by- $params->get('star_slides'); The above is ONLY a partial answer based on what I did so far. My goal is to extract the individual values of the fields Set 1 - Values of the first field set. /demo/slide1.jpg Content 1 Content 3 How can I do this using php?"
    – johanpw
    Jan 18, 2015 at 16:14


$test = $params->get('star_slides');



obtain a similar array

Array ( [image] => Array ( [0] => images/blog/blog_01.jpg [1] => images/blog/blog_02.jpg [2] => images/blog/blog_03.jpg ) [image_alt] => Array ( [0] => Web Designer [1] => Graphic Designer [2] => Painting Outdoors ) )


foreach ($test['image'] as $k => $v) {
  echo $v; // image
  echo $test['image_alt'][$k]; // etc.


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.