Trigger (or hide) form text fields in node creation, based on vocabulary

swopit - May 9, 2009 - 10:06

Here is what I intend to do:

I want to offer my users a node creation page to enter content. They should first choose a vocubalry from my taxonomy list (which I realised by using the Hierarchical Select Module). So they pick one definitive vocubalary, like DVDs --> Series (DVD being the Main category and Series its sub-vocabulary).
Now based on the choice my users make here, I want different kinds of form elements to appear (created with the CCK Module). In the case of Series for example this could be: a language autocomplete textfield and a Season Number textfield.
Hence if my users chose another subcategory, lets say Reading --> Magazines, I would want to appear different form fields for entering information, about magazine volume number or leading article for example.

I tried to solve this problem by using different kinds of modules and the following two seemed to be the most promising so far, however they are no solution to my problem:
- Conditioal Fields Module: This seemed to be the most promising one, however it seems not to be possible to use a previously selected taxonomy term as trigger
- Rules module: With this module it also seems impossible to use the chosen vocubalary as trigger within the same node creation form.

Momentarily I am playing around with the Active Select Module (ported to 6.x http://drupal.org/node/302397), however not with great succes.

I also stumbled upon this hint http://drupal.org/node/189481. It is about triggering additional form fields using JQuery. It seems to be an alternative, however as my jquery knowledge is not very good (yet), I do not dare to play around with this option at the moment.

Hence my question, if anyone of you Drupalers out there has/had similar issues? Is there maybe a module that I did not discover yet, and which I could use?

Any help is highly appreciated!
I will of course update this post when I figure something out myself.

Greetings to you all!

Patrick

update

swopit - May 12, 2009 - 11:02

Based on some research I came up with the following solution so far. I did not have time for testing yet though.
Please tell me what you think about it.

$('Hierarchical-select-1-wrapper')
.bind('change-hierarchical-select', function(hsid, updateType, settings) {
var selectedTermTid = $('#' + settings.select_id).val();
var info = $doAjaxCallbackToGetInfoAboutThisTerm(selectedTermTid);

if (info = Filme) {

$(document).ready(function(){
function() {
$('SelectedTermTid').change(

function () {
$('CCK-group-ID-1').show();
$('#CCK-Form-Div-2').show();
}
);

$('CCK-group-ID-1).hide(0);
$('#CCK-Form-Div-1').hide(0);
}
);
}

if (info = Serien) {

$(document).ready(function(){
function() {
$('SelectedTermTid').change(

function () {
$('#CCK-Form-Div-3').show();
$('#CCK-Form-Div-4').show();
}
);

$('#CCK-Form-Div-3').hide(0);
$('#CCK-Form-Div-4').hide(0);
}
);
}
});

I am however also wondering, if this could be also done using a computed field?!
The huge advante would be of course the easy re-arranging by drag and drop in the CCK fields area...

I was wondering how this

wxman - June 5, 2009 - 18:56

I was wondering how this worked for you? I'm trying to do a similar thing, but in a Public Profile section of the Users profile. I just want the results of a taxonomy pull down to decide what the next taxonomy pull down has in it.
So far I haven't had much luck.

 
 

Drupal is a registered trademark of Dries Buytaert.