Jump to content

Safari not reading a repeater field. Chrome is fine.


Recommended Posts


Hope you can help. I created a repeater to populate and dropdown with in the admin so the client can add/edit product categories for their shop.

It's all working as expected in Chrome but noticed when testing i'm echoing out 


Safari is not outputting the category names like Chrome is. My brain is fried with this so I thought I would reach out.  I'm guessing I may need to loop the selectfromrepeater and push the name? just odd that chromes is out putting them fine

This is how i'm creating JSON feed:

foreach ($activeProducts as $m) {
	$data[] = array(
		"id" => $m->id,
		"product_title" => $m->product_title,
		"product_description" => $m->product_description,
		"product_price" => $m->product_price,
		"product_orig_price" => $m->product_orig_price,
		"product_images"	=> array(
			"url" => $m->product_images->first()->url,
		"product_category_new" => $m->selectfromrepeater->repeaterProdCatName,
		"product_quantity" => $m->product_quantity,
		"product_active" => $m->product_active,
	echo $m->selectfromrepeater->repeaterProdCatName;	// Testing purposes

Then access it in the javascript like this:

function getProducts() {
		showProducts(<?php echo wireEncodeJSON($data); ?>);

Any pointers would be greatly received :)

Link to comment
Share on other sites

@Morphosis, welcome to the PW forums! 🙂

7 hours ago, Morphosis said:

Safari is not outputting the category names like Chrome is.

It's unlikely that this is related to browser differences. What's more likely is that you are logged in to the PW backend in Chrome (probably as superuser) but in Safari you are not logged in, or logged in as a less privileged user. So the area to focus on is fields or templates that have access restrictions.

If I understand right you have created a Page Reference select field (selectfromrepeater) and set the selectable pages to be items in a repeater field. The template used by a repeater field (named in the format "repeater_[field_name]") is not accessible by non-superusers. The idea is that users should not have direct access to repeater pages but instead must access them via the repeater field value.

So if you are defining selectable pages for the selectfromrepeater field using a selector string like this...


...then this will cause problems when a non-superuser works with the field. The "official" way to get repeater pages is via the repeater field value, so you would use the "Custom PHP code" option for defining selectable pages:

$wire->addHookAfter('InputfieldPage::getSelectablePages', function($event) {
	if($event->object->hasField == 'selectfromrepeater') {
		// Get the page that contains the repeater field however suits
		$page_with_repeater_field = $event->pages->get(1234);
		// The event return is the repeater field value
		$event->return = $page_with_repeater_field->repeater_field_name;

Technically you could stick with the selector string option and explicitly disable the access control when getting the repeater pages...

template=repeater_yourfieldname, check_access=0

...but in doing that you would be going against the way the core wants you to work with repeater pages, so perhaps better not to do that unless you're 100% clear on all details of how repeater fields work.

When debugging issues like this, the Tracy Debugger module is a huge help. The bd() method is all you need to learn to start with.

  • Like 1
Link to comment
Share on other sites

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...