I would like to use this great conditional_fields module at my project, but i have a little problem to construct dynamic controlled field, in my experiment i create 1 field as controlling field named it field_job_category and 2 fields as controlled field named it field_job_function1 and field_job_function2.
type of field_job_category is nodereference, type of field_job_function1 and field_job_function2 is text with select widget.
i create 3 node for job_category -> node/5, node/6 and node/7
i have success populate field_job_function1 and field_job_function2 using phpcode at allowed value by this script
field_job_function1 controlled by node/5 in field_job_category
$options = array('' => t('- select a job function -'));
$res = db_query("SELECT node.title, node.type, node.nid, node_type.type, content_type_job_function.field_category_nid
FROM node
LEFT JOIN node_type ON node.type = node_type.type
RIGHT JOIN content_type_job_function ON node.nid = content_type_job_function.nid
WHERE node_type.type = 'job_function'
AND content_type_job_function.field_category_nid =5");
while ($o = db_fetch_object($res)) {
$options[$o->title] = t($o->title);
}
return $options;
field_job_function2 controlled by node/6 in field_job_category
$options = array('' => t('- select a job function -'));
$res = db_query("SELECT node.title, node.type, node.nid, node_type.type, content_type_job_function.field_category_nid
FROM node
LEFT JOIN node_type ON node.type = node_type.type
RIGHT JOIN content_type_job_function ON node.nid = content_type_job_function.nid
WHERE node_type.type = 'job_function'
AND content_type_job_function.field_category_nid =6");
while ($o = db_fetch_object($res)) {
$options[$o->title] = t($o->title);
}
return $options;
My question is
- if i need 30 node as controlled field in job_category, should i create 30 field named field_job_function_0 .. field_job_function_30 as controlling field?
- are there other way to replace my script to reduce number of field? so i only need 2 field, 1 for controlled field and 1 more as controlling field
Thanks a lot for all of your help
Comments
Comment #1
anjjriit commentedSorry my title is should be Dynamic controlling field using php code at allowed value
Comment #2
peterpoe commentedClosing ancient support requests.