Jump to content

What input field type to use?


Robert Zelník
 Share

Recommended Posts

I have a list of articles and a hierarchical tree of topics. In the "article" template I have added the "topics" field to link the topics. I would like to allow linking multiple topics from the whole tree. The "Dereference in API as" is set to "Multiple pages (PageArray)". My question is: which input field type should I choose in this case?

  • SelectMultiple and AsmSelect allow to choose from the root topics only
  • PageListSelectMultiple allows to choose from the whole tree, but it stores the root level only. When I choose from the nested level, this choice is ignored during saving.

Is this a bug or a feature?

(I use 2.1devel version of ProcessWire.)

Link to comment
Share on other sites

How have you configured your fieldtype? You probably have setting "Parent of selectable page(s)" -> this mean that you can select only direct children of the selected page - so it works as expected.

Easiest solution is to have common template for all topics (ie. "topic"). Then leave "Parent of selectable page(s)" empty and select "topic" from "Template of selectable page(s)".

If you don't have or don't want new template for your topics, then you have to write custom selector to "Alternate/custom code to find selectable pages". That is not very complicated, this should work:

return $pages->get("/topics/")->find();

Code above assumes that you have page /topics/ which keeps your topics tree. And of course you could use ->get(5232) where 5232 is page id for your topics page (so that selector would work even if you decide to move your topics page).

Link to comment
Share on other sites

@Apeisa: Thanks for the tip with custom selector. I didn't notice this field before  :)

I think it would be nice to extend PageListSelectMultiple's functionality so user could select not only direct children of selected page but also, optionally, all its descendants on lower levels. It would eliminate unncessary clicks to get to the parent of selectable pages (which you should do currently if you didn't select any parent) and user still would use three structure to select pages (which is not the case with SelectMultiple, AsmSelect and custom selector) limited by the branch under selected parent.

Link to comment
Share on other sites

The PageListSelectMultiple is supposed to work with parent, at least that was the intention. If it's not working (not saving your descendent selections), then chances are it's a bug... An over-validation. As a temporary solution till I get back, try what Antti suggested, or just set no criteria at all for the pages, and see if you can just let it work with the entire site tree, temporarily.

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...