Jump to content

Multiselect field of custom information from PHP


nathan
 Share

Recommended Posts

I am looking to create a multiselect field that allows a user to select some PicasaWebAlbums on the admin side of PW.

I know how to get the PicasaWebAlbums list and all, but it requires PHP. I also know how to make a multiselect field the Page input type and defining which parent holds the select options, etc.

What I do not know is how I can create a custom multiselect field that is generated via PHP.

For example:

I have a list of albums from PHP (these are not actually what I have but you get the point):

- id: 1000, title: Album 1000
- id: 1004, title: Album 1004
- id: 1008, title: Album 1008
- id: 1005, title: Album 1005
- id: 1003, title: Album 1003

How do I make a multiselect field where the options are:

<option value="1000">Album 1000</option>
... etc ...

Is this possible? Do I have to make a module? Point me in the right direction :)

Link to comment
Share on other sites

As your data for the inputfield isn't from the database processwire has no way of understanding your data. So you need to write a fieldtype module where you define, which data would be saved in which way to the database. That's nessesary, so your users can actually choose something. You could write this from scratch or extend a existing fieldtype. The other thing is the inputfield module, which manages only the inputfield as part of the forms in the backend and the processing of submitted form data.

//Edit: This helped me greatly getting started with my first custom fieldtype: https://github.com/somatonic/FieldtypeDimension

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...