cst989 Posted October 6, 2021 Share Posted October 6, 2021 Hi, I'm using a repeater in the following manner: I have set the minimum items to 5, and the maximum number of items to 5. I basically just want to loop through a few fields five times. But I feel like I'm really forcing the repeater to do something it's not really meant for by doing this. A table would look and feel better, but as far as I know can't be fixed to x rows/pre-populated. Also there's a technical problem with this. Repeater rows do not seem to save unless you change something. So if I make a new page with the fields above and hit save, no data is actually available for the field. In my screenshot you can see that items #1 and #5 have saved because the type has been changed to 2 - they're solid and don't say "New" anymore. Also item #4 has saved because the type was changed and changed back. But #2 and #3 won't ever save unless you change the value. If there's not a better suggestion for the approach in general - I would appreciate any technical support in forcing each row to save! Link to comment Share on other sites More sharing options...
zoeck Posted October 6, 2021 Share Posted October 6, 2021 Do you know the "Combo" ProField?https://processwire.com/store/pro-fields/combo/ I'm not sure, but I think this might be just the right thing for you ? 1 Link to comment Share on other sites More sharing options...
cst989 Posted October 6, 2021 Author Share Posted October 6, 2021 You know what, I have a long expired subscription for ProFields and I have been weighing up whether or not I need to renew ? I will take a look, thanks Link to comment Share on other sites More sharing options...
Robin S Posted October 6, 2021 Share Posted October 6, 2021 12 hours ago, cst989 said: A table would look and feel better, but as far as I know can't be fixed to x rows/pre-populated. The Limit Table module (previously not in the modules directory but I just added it) adds this feature to Profields Table. 2 Link to comment Share on other sites More sharing options...
cst989 Posted October 7, 2021 Author Share Posted October 7, 2021 That looks great! If "show all rows" is selected, and you open and save a fresh page with that field, does it actually save rows for you to iterate through? Per my issue at the end of my first post -- it caused me some issues with repeater Link to comment Share on other sites More sharing options...
Robin S Posted October 7, 2021 Share Posted October 7, 2021 7 hours ago, cst989 said: If "show all rows" is selected, and you open and save a fresh page with that field, does it actually save rows for you to iterate through? I believe so, but the simplest thing would be to try it and see. Link to comment Share on other sites More sharing options...
cst989 Posted October 29, 2021 Author Share Posted October 29, 2021 I didn't get as far as checking if a table field would save the rows when they were new, because unfortunately table doesn't offer as many options that I needed, like a default option on selector, or the ability to show/hide fields I ended up sticking with the repeater matrix but forcing the repeater to publish on save. I tried the following, it worked at first but then it started creating database errors.... $this->addHookAfter("Pages::saveReady", function (HookEvent $event) { $page = $event->arguments("page"); if(!($page->hasField("featured_articles"))) return; foreach($page->featured_articles as $item) { $item->of(false); $item->status("published"); $item->save(); } }); now I think I'm just going to create 5 separate fields of "fieldset (page)" type ? 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