-
Notifications
You must be signed in to change notification settings - Fork 571
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Repeating Groups with Repeating Text Fields #348
Comments
I was running into the same problem with repeating fields inside a repeater. Also had seemingly random data loss, couldn't discern any sort of pattern. |
Hey folks, I'm also seeing random data loss when using repeatable fields inside a repeat group. We've also noticed that the sorting function may also be responsible for data loss in the same instance. Here's a gist of my code for reference. https://gist.github.com/mikemcalister/be840ff5cb9243c63bfd |
Could this be reaching the internal $_POST limit in PHP for how many input_vars it will process? |
Relevant PHP config vars are |
This might be slightly off-topic, but I think I'm running into a post limit as well, but with creating more than 99 repeating groups. Any time I create a 100th group and save, the 100th group does not get saved. There seems to be hard limit on 99 repeating groups. |
I was able to solve my issue of data loss by increasing the max_input_vars as @sc0ttkclark had suggested. Thanks, Scott! You can increase that limit a few different ways. If you have access to your php.ini file, you can change it there. Otherwise you can add it via your .htaccess file by adding this:
|
@mikemcalister it worked (.htaccess). Thank you! |
No problem! I stress tested it with many, many inputs with no issues. Feel free to push that number up if you need to. |
wow, nice suggestion @sc0ttkclark. Also wow guys.. 100 groups! shudders |
beautiful!!! |
@jtsternberg once you give people an admin UI to do all this, things get crazy, I've seen actual sites using Pods with hundreds of content types (post types, taxonomies, advanced content types, etc), with 50-150 fields each, it's just dang crazy what people do with what we make. We ran into this very issue ourselves. Our solution was actually to take each 'row' of fields and json encode them before the form save kicks off. The problem stemmed from the Pods Admin area, where we let you edit a Pod and all of it's fields from one screen. Each field expanded to allow you to edit a few main fields, but there were tabs with other field options available too. All total, maybe 20-40 inputs per field would be on the page to POST. Add 20-30 fields, and that really starts adding up. We found this when testing Pods 2.0 and had to resolve it through our json hack-around. In our AJAX action handler for saving the Pod, we had to loop through all of the fields passed in, then json_decode the data: https://github.com/pods-framework/pods/blob/master/classes/PodsAdmin.php#L2315 Yep, it was fun times. We broke PHP, we broke much of the world. But I share that knowledge with you, for I see that we'll be having much more fun with CMB2 group fields in Pods too :) |
Ha ha @sc0ttkclark, those are stories you'll be able to pass on to the next generation. That being said, your experience in that area will be invaluable. |
Woow!! Really amazing and helpful!.. |
Hello All, I've run into this bug and haven't been able to resolve it using the PHP config vars. I have a Repeatable group which contains a repeatable text field. If I create one group everything works fine, however, when I make a second group with another 5 text fields - the data gets messed up on save. Here is the result after making a second group of the same # of text fields and saving.To replicate:
When you refresh the page:
Here's the sample code:
Thanks in advance! |
Something is definitely getting mangled up during the save/serialize process, but I'm not sure what, and I have to wonder if its in part because of the javascript involved to repeater fields. As an alternative, in case you're willing to consider it, perhaps try out setting a cap at amount of custom rate details can be added, and provide a field for each. Say 5 total. Just a thought. |
Yeah, that was my fallback, just wanted to see if the repeater would be useable first. cheers! |
I am running into same problem as @ogdsgn asked, and this problem is still unsolved. |
This issue persists - when user creates multiple group elements width multiple repeating fields inside they get sorted inside these group elements. This one is a really annoying bug serialization/save bug((( |
I did a bit of debugging on this issue today and believe I've identified the issue, but unfortunately didn't get a working patch. The problem seems to be coming from the The regex in this function is replacing the first instance of the previous index with the next index. The problem here is that when you have a repeatable field inside of a repeatable group, there are multiple indices that need to be taken into account. For example, assume you have these fields:
The name for the first field in the first group will be: Following these steps, and you'll get the following field name results:
What appears to be happening is that the If you continue adding new Groups, each with three or four fields in it, you'll notice that the field names get further and further off from being correct. It's because this regex keeps replacing the first match it finds, regardless of that match being the group's index or the field's index. I believe the best way to fix this is to separate this into two functions, one for creating a new group and another for creating a new field. This way, we can tell the "new group" regex to only replace the first match found starting at the beginning of the string, and we can tell the "new field" regex to replace the first match found starting at the end of the string. In my attempts today, I was trying to do something quick and dirty to determine if a field or group was being created, and adjust the regex accordingly, but I didn't have much luck with that approach. Regardless. To clarify, I am 99% sure this is a javascript bug and not a php serialization bug because the problem is very apparent when inspecting the fields as they are created. |
Found a related issue with a patch: #1035 |
We lean on CMB2 to create quizzes. These quizzes have questions (repeatable groups). Within each question, the admin can create answers (repeatable text field). Here's an example of one of the repeatable groups structure.
When the data is saved, it removes all but one of the questions. To replicate:
When you refresh the page:
Here's the sample code:
The text was updated successfully, but these errors were encountered: