Jump to content

Recommended Posts

Posted

I'm stumped.

I have a repeater setup like so:

                        Repeater

      Repeater 1                 Repeater 2

Field 1      Field 2         Field 1      Field 2

If I know the ID of Repeater 1, how do I get the value of one of its child fields?

I tried  $page->get(id)->field_2  to no avail.

What I'm trying to do is maybe a bit complex/weird. Basically, I am looping through a repeater to populate a select box in a contact form (non form-builder, just my own php in the template). I need some sort of id to serve as the value attribute on the select option so that I can then use it to identify and pull the data from the other field in the same instance of that repeater when the form gets posted.

I hope that sort of makes sense...

Posted

I'm not sure if this is still possible, but you should not use nested repeaters (repeater in repeater).

Can you give an example code of what you want to achieve, I think I didn't get it :)

Posted

It's not a nested repeater-- I'm just showing that it is one repeater with multiple instances on the page, i.e. it has two "items" added to it, with each item consisting of two fields.

So I guess the real question I'm asking is, how do I call just one of the instances of a repeater in the wirearray through the api? Should ID work?

Posted

What id, and from where you got it?

If you got the repeater id (which is a page behind the scenes) you just do.

echo $pages->get($id)->myfield;
  • Like 2

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...