neosin

[solved] Selects within selects?

Recommended Posts

I have a template that allows multiple "people" records to be attached (basically tags) however each of those "people" can also have multiple "role's" selected from a drop down.

is it possible for tags to have tags and if so how can it be accomplished?

For example a "video" data page where the content editor can add multiple people names (via select list) and the roles of each person (via select list)

I am probably over complicating this in my head again regarding how to do it in PW, any help de-muddling this in my mind would be much appreciated

I have the add multiple names working using asmselect but am not sure how to add the select role option dynamically to each name once added.

I am thinking there should be a table with 2 columns where the first column is the user name and the second column is the role and when you insert new record it adds a new row allowing to select a single name and role for the new insert.

The "people names" and the "roles" come from different templates since people can have different roles in different videos

thank you

 

 

Share this post


Link to post
Share on other sites

@neosin After you select asmselect as your input field type, check the "Settings specific to “asmSelect”" below.

There you have "Link selected pages to page editor?" that lets you open the selected page in a modal and edit any fields that page has.

You can also create new pages from the page ref field (check the "Allow new pages to be created from field?" option).

Share this post


Link to post
Share on other sites

@fbg13 thank you, Sorry I don't quite grasp this explanation since the people page only uses "title". Are you saying I need yet another template and fields to merge the "people" and "roles" for each video? The people and roles are "predefined" and exist already

Here is my current setup:

Template name: videos
field: title
field: body
field: people type: asmselect

Template name: people
field: title

Template name: roles
field: title

ideally this is what an editor would see when editing a videos template record

field "people":  [drop down list of names] [drop down list of roles] [button "ADD"]

example usage for new video page record: 

title: Example Video
body: Video description
people:
[ "Bob Smith" ] [ "Producer" ]
[ "John Doe" ] [ "Director" ]
[ "Bob Smith" ] [ "Catering" ]
[ "Bob Smith" ] [ "Sound Editor" ]

Share this post


Link to post
Share on other sites

One way to do something like that is with the repeater field.

You have a repeater field and the repeater has two page ref fields (people, roles).

And you repeat the fields for every person.

image.png.4af8e4caa9ba601b9bbcdb0c5aa2a8e2.png

 

The way i described in my first comment the roles field would go to the people template, so on the video page you would only have the people field. You add a person and then click on it, a modal opens to edit the persons page where you can set the role.

  • Like 2
  • Thanks 3

Share this post


Link to post
Share on other sites

@fbg13 thank you for this, I will investigate repeater fields (I haven't tried them yet)

thank you!

Share this post


Link to post
Share on other sites

@fbg13 it works! thank you so much, the repeater is what I needed. I am still learning how the PW and the different fields work

thanks again

Share this post


Link to post
Share on other sites

now I just have to figure out how to access those video template repeater fields through the API

Share this post


Link to post
Share on other sites

According to the image above.

// loop over repeater items
// repeater is the name of my repeater field
foreach ($page->repeater as $r) {
	// person is the name of my page ref field for selecting persons
	// can hold a single page (can be set in field's settings, details tab)
	echo $r->person->title, " ";

	// skills is the name of my page ref field for selecting skills
	// can hold multiple pages so we have to loop (can be set in field's settings, details tab)
	foreach ($r->skills as $s) {
		echo $s->title, " ";
	}
	// or use eq
	echo $r->skills->eq(0)->title, " ";
	echo $r->skills->eq(1)->title, " ";
}

// outputs
// Jim Programmer Designer Programmer Designer
  • Like 2
  • Thanks 2

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.