use multiple fields in repeatable fieldset

33 views
Skip to first unread message

piete...@tenzer.nl

unread,
Oct 3, 2016, 5:25:49 AM10/3/16
to Joomla! General Development
Hi,

i made a simple module to show some reviews, using a repeatable fieldset:

<field name="reviews" type="repeatable" label="Reviews" filter="raw">
                   
<fieldset hidden="true" name="reviews_modal" repeat="true">
                       
<field name="review" type="textarea" label="Tekst" />
                   
</fieldset>
</field>


and outputting it in a bootstrap carousel this way:


<?php


defined('_JEXEC') or die;


$document
= JFactory::getDocument();


$fields
= json_decode($params->get('reviews'), true);
$reviews
= $fields['review'];
?>


<div class="carousel slide" id="tenzer-reviews-
<?php echo $module->id; ?>" data-ride="carousel">
   
<ol class="carousel-indicators">
       
<?php foreach ($reviews as $key => $review): ?>
            <li data-target="#tenzer-reviews-
<?php echo $module->id; ?>" data-slide-to="<?php echo $key . ($key == 0 ? '" class="active' : ''); ?>"></li>
       
<?php endforeach; ?>
   
</ol>


   
<div class="carousel-inner">
       
<?php foreach ($reviews as $key => $review): ?>
            <div class="carousel-item
<?php echo $key == 0 ? ' active' : ''; ?>" >
               
<p class="reviews-review"><?php echo $review; ?></p>
           
</div>
       
<?php endforeach; ?>
   
</div>
</div>


Works fine, but now i want a second formfiled for each item (a name belonging to the review), so:

<field name="reviews" type="repeatable" label="Reviews" filter="raw">
                   
<fieldset hidden="true" name="reviews_modal" repeat="true">
                       
<field name="review" type="textarea" label="Tekst" />
                       
<field name="name" type="text" label="Naam" />
                   
</fieldset>
</field>

but i cant figure out how i should output this... Any help would be very, very welcome and appriciated!



piete...@tenzer.nl

unread,
Oct 3, 2016, 6:42:42 AM10/3/16
to Joomla! General Development
never mid, 


<?php echo $fields['name'][$key]; ?>

does the trick
Reply all
Reply to author
Forward
0 new messages