I have been trying to find the best way to create a set of dependent dropdowns (selections in one field determine the allowed values for another field).
The Allowed Values PHP Code snippet is the obvious place to do this but I have not found a good way to reference other field values from within this "hook" in CCK.
The following code snippet example is close
but it does not give me a way to make things dependent on other fields in the form.
It then references a tutorial at http://blue.live4all.co.il/~mooffie/cms/node/17 which creates a workaround to get to the context of other input fields, but this module (cck_context) does not seem to work with Drupal 6 even though at one time it seemed to be a best practice.
I have looked at Hierarchical Select (need this to work with straight user-created content not taxonomies or flat lists), Option Trim (not dynamic enough and the manual assignment of selections makes it unscalable), Fixed Data Dropdowns, ActiveSelect (why no Drupal 6?) and a number of various forums posts describing how to do this, but these all seem to be very extensive solutions to a simple problem. IE I already have a place to put PHP Code to do what I want, but I just do not know how to reference the right data in the code snippet.
It seems really odious to have to write a new module just to make the CCK Allowed Values PHP code be able to reference the current state of other input fields (okay the tutorial above does just that but the cck_context module simply provides a way to pass that state around, it is not a complete replacement input module).
Which leads me to the actual question being asked. It is a minimalist question, which I think fits the CCK philosophy. Note I did not ask how to do dependent dropdowns, I asked how to reference the context of other input fields from the CCK Allowed Values PHP code in Drupal 6.
Comments
subscribing
subscribing
+1 we have very lazy
+1
we have very lazy customers with d5 installed, who want to create node type with cck fields:
1. field_auto_brand (Taxonomy Field with HS and 2 levels) - from this field you can just find in big vocab your auto brand and model.
2. If you can not find your brand in 1st HS field, you can just type this in 2nd - field_auto_brand_taxonomy with same type (Taxonomy Field)
this is done without questions and all works fine, but for 2nd way (manual input) we must add 3rd field (again with Taxonomy Field type), but in this autucomplete field we must form only the list of values (taxonomy sub-terms) of 2nd field.
so, if i can't find in 1st HS field (or i have no motivation and time) my brand, i can just input 2 first letters (BM for BMW) and i can see and select my brand quickly, after it i must select (by typing letters of model) in 3rd field and 3rd field must have in allowed values only sub-terms of term, inputed in 2nd field, or can give me input my model by just typing.
any ideas?
maybe anybody seen module for taxonomy with combining HS+autocomplete in one field ?
I've been looking for a way
I've been looking for a way around this as well - I can't see much around it other than what the OP as mentioned.
Here is my use case:
- I have two content types, Application and ApplicationMembership
- Application A has a cck text field with multiple values that the user can change. ie. FREE, PREMIUM
- ApplicationMembership AM has a node reference to Application
- ApplicationMembership has a cck text field which should *ONLY* contain values from the text field from the node reference ie. allowed values should be FREE, PREMIUM
The comment in the tutorial from the OP describes it perfectly:
Why do this? Well, you may not want to give users access to edit a content type, but allow them to restrict the 'allowed values', which can be done in a separate node.
It might be a good idea to use a combination of:
views_attach, views_customfield, hs_field_selector, conditional_fields
You can then hook into the appropriate form.
Issues of note:
#632236: cck field from another cck field as Allowed values list
#658636: How to access current, loaded node from Allowed Values PHP Code?
#621970: CCK dropdown field in a View? and access $node in cck 'allowed values'?
ionmedia: Perhaps you can use autocomplete_widgets ?
www.pixelchefcreative.com
www.pocoapps.com