Forum

Thread tagged as: Question, Problem

Perch If and value inside repeater

I have a repeater on the page I'm building, which is has a h4 title... I don't want to display the h4 title if no values are entered into the repeater, so I've wrapped the section in an if statement.

The issue is, I've set my <perch:if> with the value of the content inside the repeater... but now, nothing shows even if content is added to the repeater

here is my code. - When no value is entered into course-id, I don't want anything to show

<perch:if exists="course-id">
    <h4 class="course-titles">Currently Available Courses</h4>
        <perch:repeater id="course-codes" label="Course Codes">
            <perch:content id="course-id" type="text" label="Course Code" textile="true" editor="markitup" required="false" help="Enter Course Code" append=", "/>
        </perch:repeater>">
</perch:if>

How do I use an id inside the repeater with the <perch:if> so it doesn't show anything if nothing is added to the repeater?

Nik Gill

Nik Gill 1 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Your IDs contain dashes - it could well be that.

Hmmn, yeah... that's an idea!

However, I've taken the dashes out and I'm still getting the same result

<perch:if exists="courseid">
<h4 class="course-titles">Currently Available Courses</h4>
<perch:repeater id="coursecodes" label="Course Codes">
<perch:content id="courseid" type="text" label="Course Code" textile="true" editor="markitup" required="false" help="Enter Course Code" append=", "/>
</perch:repeater>">
</perch:if>
Drew McLellan

Drew McLellan 2638 points
Perch Support

Wait.. courseid in inside the repeat, but you're testing for it outside.

I think the better approach would be to the the h4 in the repeater's perch:before section.

Thanks Drew, I've done it that way and it's worked fine thanks.