Jump to content

Items of Page Reference Field from field within Repeaters


jothanne
 Share

Recommended Posts

I have the following page and field setup:

root_page (Page)
|
|- colors_page (Page)
|  |
|  |- type_repeater (Repeater Field)
|     |
|     |- color_repeater (Repeater Field)
|        |- colorname_text (Text Field)
|        |- coloropt_options (Select Options Field / Multiple values)
|           (1=usable, 2=preferred)
|
|- products_page (Page)
   |
   |- product_repeater (Repeater Field)
      |- product_color (Page Reference Field)

Now i want to fill the entries of the 'product_color'-field with only the color names ('colorname_text'-field) of the colors which are 'usable' (value=1) corresponding to the 'coloropt_options'-field within the nested repeaters 'type_repeater' and 'color_repeater' of the 'colors_page'.

I researched and tried a lot, but cant't really get around this problem. As a temporary workaround i replaced the repeater fields by subpages - but that isn't what i want in the end. And now i hope for a helping hand to give me the essential advice or hint.
Thanks a lot in advance.

Link to comment
Share on other sites

Hey @jothanne,

Welcome to ProcessWire/the forums.

I don't get your setup entirely. Do you have a repeater nested within a repeater? i.e., is type_repeater a repeater field that also contains the repeater color_repeater?

Normally for the sort of logic you are after (for page fields), you can use the Custom PHP Option (see the input tab of your page field product_color). I'm not sure this solves your problem though as I don't fully grasp your setup.

Link to comment
Share on other sites

Hi kongondo,

Thanks a lot for your reply! Yes - the type_repeater (repeater field) contains the repeater-field color_repeater.

I saw this 'Custom PHP Option' and suspected that might be the way to go, but can't really find out, how to adapt this for my use case. Maybe you can give me a hint or a small code example to do the trick.

Link to comment
Share on other sites

OK, I get you.

On 9/13/2018 at 8:44 AM, jothanne said:

Now i want to fill the entries of the 'product_color'-field with only the color names ('colorname_text'-field) of the colors which are 'usable' (value=1) corresponding to the 'coloropt_options'-field within the nested repeaters 'type_repeater' and 'color_repeater' of the 'colors_page'.

My understanding is that you will have ONE colors page which will hold ALL your colours whereby the different colours are defined within the repeaters?  You then want these colours (the ones that are usable) to be individually selectable within page reference field product_color? Meaning your page field will show  brown,green,red, etc? Unless I've missed some recent PW feature, you can't do that. Only pages are selectable in page reference fields. So, you would have to change your approach. 

Let me know if I'm still missing the mark :-).

 

Link to comment
Share on other sites

Hi kongondo,

your understanding is completely right. Sadly to read that this isn't realizable the described way - but I suspected something like that. So I went the way with my initially described - now not so - 'temporary workaround'.

It seems that my fault was to think of the repeaters as a special kind of subpages-layer with a somehow similar behavior. OK - maybe the future will bring this feature since I'm a big fan of the repeater-technique and the associated clear arrangement in the pages tree of the user interface.

Thank you for your efforts to clarify the issue.

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

×
×
  • Create New...