androbey Posted June 23, 2018 Share Posted June 23, 2018 Hi everyone, I have problems once again. This time it's about setting a certain field of a repeater item from a different page. This is what I have so far: I create a new repeater item on Page A via api using following code: // template of page A $item = $page->repeater_field->getNewItem(); //set content to fields.. $item->save(); $item_id = $item->id; //returns e.g. for $item_id = 1222 Now the goal is to set a field of that particular repeater item from Page B. But I am not able to get to the particular repater item to set a field. // template of page B $ref = $pages->get($page->page_a_reference->id); //With following code I get the repeater field items, but I cannot access (or determine) the repeater item I would like to get (with ID 1222). $rep = $ref->repeater_field; //Following code returns null //$rep = $ref->get(1222); What do I do wrong, or better asked, how can I set a field of a repeater item from different page? Link to comment Share on other sites More sharing options...
elabx Posted June 24, 2018 Share Posted June 24, 2018 Try: $rep = $ref->repeater_field->get(1222); It should get the you the repeater item with ID 1222. This is a RepeaterPage which is pretty much a normal Page object. I don't have very clear how you know which repeater item you want to edit and where are you getting the data that is meant to be set on the repeater items. Every repeater field is an array of pages, where you can also use the find/get methods to match pages through selectors. Also, every repeater Item can have it's fields set and saved pretty much the same as normal pages. 2 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now