Jump to content

Reapeater reference breaks after changes are made to a used repeater field.


dewwwald
 Share

Recommended Posts

If you have a repeater that is already being used, in a template, and containing content, ie 
$repeater
  |_ body (this can be any field)
  |_ image  (this can be any field)
 
And you add a filed to said repeater, 
$repeater
  |_ body (this can be any field)
  |_ image  (this can be any field)
  |_ summary  (this can be any field)

When you want to update existing instances of that repeater item the it does not want to save that repeater field, I cant delete upload or add new items to this repeater.
 
Is this a bug?
Do you need more info?
Should I make an issue?
Link to comment
Share on other sites

Hi @LostKobrakai,

Thanks for the swift reply.

I am getting no errors in admin.

I am using the latest version of ProcessWire (free) as found on github master branch.

When I delete a file after the repeater update I get this messages at the top,

http://snag.gy/CyTUr.jpg

Did you follow my instructions carefully?

-- Edit introduce spec --

starting point

- repeater contains field

- repeater is used in a template

- repeater has content

- lets add a file field with content to be sure

introduction of error can be done by

- making an update to repeater field by adding new fields

Test If error works

- delete file field content

- save page

-- Edit end --

I am using a file field in my live version of this issue, this might be where the problem starts as you said you needed an image to reproduce the issue. I can resolve it, and have in the past by redoing everything in the field with my updates.

Link to comment
Share on other sites

Even on the master branch and with an image field I can't reproduce it. I can add fields to the repeater and have no problems updating previously created repeater items. Any errors in the javascript console regarding the image upload? What modules do you have installed?

Link to comment
Share on other sites

I can upload a new pdf in the place of the old one, but i can not delete the existing one, having an empty field. Field is not required. No js errors.

-- edit introduce --

I want to emphasize that please follow the post instructions taking in to account the clarifying description

  If you have a repeater that is already being used, in a template, and containing content, ie 

$repeater
  |_ body (this can be any field)
  |_ image  (this can be any field)
 
And you add a filed to said repeater, 
$repeater
  |_ body (this can be any field)
  |_ image  (this can be any field)
  |_ summary  (this can be any field)

When you want to update existing instances of that repeater item the it does not want to save that repeater field, I cant delete upload or add new items to this repeater.

Did you follow my instructions carefully?

-- Edit introduce spec --

starting point

- repeater contains field

- repeater is used in a template

- repeater has content

- lets add a file field with content to be sure

 

introduction of error can be done by

- making an update to repeater field by adding new fields

 

Test If error works

- delete file field content

- save page

-- Edit end --

Link to comment
Share on other sites

Modules installed are ProcessRedirects, MarkupSImpleNavigation, MarkupSitemapXml.

After extensive testing I reproduced this by adding another repeater to the same page that already has another repeater.

Disabling said modules does not fix the issue.

I introduced the error after finally installing MarkupSimpleNavigation (the last of the modules) and adding a second repeater with the same fields to the same page.

I will make a site profile export, but don't see the need. But here is a headsup on how this was done.

Link to comment
Share on other sites

Here is the site profile that broke the repeaters.

Steps taken

- Install

- add repeater item

- set up file and page item to work, use max 1 and null if empty, set template | parent page

- add page, title and file to repeater

- add repeater to a template

- add items to repeater

- add an image to the repeater, be sure to set up 1 max and null if empty

- add module ProcessRedirects

- Make changes to repeater by adding another field, I added a checkbox that when checked makes a field available

- add module MarkupSitemapXML

- Nothing broke yet

- fiddle with the repeater template setup

- hmmmm add MarkupSimple navigation

- add a repeater_2 field

- add fields in repeater one

- add repeater to same page

- broken repeaters

- remove MarkupSimpleNavigation

- does not fix the issue

- add markup simple navigation

- make a site export

Here we are.

site-BreakRepeaters.zip 

Link to comment
Share on other sites

  

I am using the latest version of ProcessWire (free) as found on github master branch.

Could you please list your actual version numbers (PW, PHP, MySql, Apache)?  Thanks

Edited by cstevensjr
Updated to add MySql
Link to comment
Share on other sites

Okay, I think I am going to try and do something:

- Make repeatable steps that wont fail, (for me at least)

- Clearly define these steps at every point and turn

- As suggested by one of my mentors I will also create a diff of the db dump before it breaks and after it breaks at the point I find it breaking.

eta Monday 6th 17h00 GMT+2.

For now here is my details of the machine I am working on.

- Ubuntu 12.04 (I know I'll update asap...)

- Apache version 2.2.22

- php 5.4.39-1+deb.sury.org~precise+2 (cli)

- mysql  Ver 14.14 Distrib 5.5.41, for debian-linux-gnu (x86_64) using readline 6.2

- PW version 2.5 - as said I did this with a master branch clean install

I really would like to get to the bottom of this, helping you guys where I can, I am however swamped at current time, but will try my best to help as much as I can, please understand.

Link to comment
Share on other sites

Going to start work on this about now-ish, I will create a github repo, with db exports est, so there will be no chance of the site profile exporter solving the issue, the workflow will therefore be, clone github repo, reference your vhosts (if used) and import the db dump.

Good luck :).

--edit add github repo link--

https://github.com/dewald-laubscher/processwire

--edit work in progress--

Structure to do this setup, now to move on to breaking stuff

Link to comment
Share on other sites

Does not solve the issue, I have a workaround.

Clearly this adventure was as a result of a lack of knowledge. As part of the splution I will explain what I have done and what the workaround was. LostKobrakai has stated:

Repeaters are not officially supported by inputfield dependencies. 

This means that you should avoid inputfields in repeaters as far as I can gather.

The use case

Lets say I have a template that I call resources, this page has some basic content and also a repeater. The repeater Item can either be used for navigation to an internal page or a file that is uploaded and downloaded. So we want the user to lose or gain functionality based on what he or she wants the repeater to do. For instance we want page to show only if file is blank and we also want file to show only if page is blank. So one or the other will be used and not both.

The broken solution

Adding this here for the sake of completeness.

I originally thought I would solve this issue by adding two checkbox fields to the repeater and have page and file hidden if their checkbox is not selected. Even more have the checkbox that shows the other field hide when the first checkbox is selected. I did this by using the 'hide only if' functionality found in processwire on the input tab of each field. There I simply added a condition 'checkbox=0' for the checkboxes and 'checkbox=1' for the field relating to the specific checkbox. Though this is a good solution that looks nice in admin. Its the very same thing that breaks repeaters. I think it might have been the page field having a condition.

A work around

My solution to this is to simply add the page and file field. Have the file field hide when page is populated (this does not work on page selector fields). Now have my php output the page field markup if it has an item else ill output the file field markup.

Link to comment
Share on other sites

I will argue that point, as page table, tough awesome and logical for a developer seems to have some complexity that a user, unfamiliar with processwire, might find complex. Although it can replace a repeater it is not always the most logical way to work. For what if the content is specific to that page or section of the page. It depends on the situation whether repeaters are good to use, other methods might be better for a dev, but look complex for a user.

a kind of, "You want to keep your bananas away from your apples, or the apples might go down faster. " situation.

After all CMS is supposed to be for a end user when it reaches them not for the dev. So their perspective is primary, especially since our paradigm is that of a super user. 

Link to comment
Share on other sites

yeah, sometimes repeaters are quite essential and un-replaceable, as problematic as they are from the api perspective.

where possible i try to use profields table, pageTable, multiplier, or textareas; but once in a rare while, those repeaters are good.

  • 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
 Share

  • Recently Browsing   0 members

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