Jump to content

Custom PHP code to populate select option values in admin

Recommended Posts

Custom PHP code is available for use in PageReference field type. Is it possible to use custom php to generate the values for a Select Options FieldType?? 

What I'm to trying to achieve is to generate values for a options field from values for repeater in a grand parent's page (parent of parent page).

Share this post

Link to post
Share on other sites
7 minutes ago, Sérgio Jardim said:

Oh yeah! See:


That post was NOT for modifying the field options but to save an options selected in his form. Probably front-end stuff.

What I'm looking for is a solution to the backend to dynamically set/modify selectable options based on field values from grand-parent page.

I came across something close. https://github.com/BitPoet/FieldtypeDropdownDynamic

But it has not been updated for 2 years and my lack of ProcessWire knowledge is keeping me from updating it.

Coming from the WordPress world, PW is very different (in both good/bad ways). In WP we store custom field configurations in php, but here its stored in DB tables.

Share this post

Link to post
Share on other sites

Didn't have time to test either of these, but you should have a look here:


Maybe one of those does exactly what you want, or at least can be tweaked easily...

Share this post

Link to post
Share on other sites

@waheed, Repeater items are pages so what you want is a Page Reference field. Set the selectable pages to the value of the Repeater field (which is a PageArray).

Share this post

Link to post
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.

  • Similar Content

    • By Flashmaster82
      Is it possible to just show a list (page reference) but without any radio buttons? Or a drop down but the references is not selectable? The items needs to be references but the main thing is that its just a list. Please help!

    • By slave
      how can I make this with addHookAfter

    • By Raul
      Hello all, 
      I have a contact-form with a select field as Subject.
      The select field is defined as:
      subject1= THE FIRST Subject
      subject2= THE SECOND Subject
      Now I call the contact-fom from another page with a get parameter "subject" :

      I have a Hook defined to process the form "onRender" and I have got the get parameter and sanitized it, etc.
      Now the question is:
      How can I select the option based on the get parameter ?
      Thank you in advance
  • Create New...