It is possible to extend support to text,password and hidden fields with the following version of ConditionalFields.findValues()
Drupal.ConditionalFields.findValues = function(field) {
var values = [];
var type= '';
$('input:first', field).each(
function() {
type = this.type;
}
);
switch ( type ) {
case 'checkbox':
case 'radio':
field.find('input:checked').each(
function() {
values[values.length] = this.value;
}
);
break;
case 'text':
case 'password':
case 'hidden':
values[values.length] = $('input:first', field).val();
break;
default:
values = $('select', field).val();
break;
}
return values;
}
Field in question must have a defined set up values.
With this change I can make a text field with values red,green,blue and a conditional field that shows when the text field has a value of 'red'.
In my situation the use case where some field X is set pragmatically and determines the visibility of other fields on the form.
Thanks for considering this change.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | conditional_fields_470968.patch | 1.35 KB | peterpoe |
Comments
Comment #1
peterpoe commentedHere's a patch against latest dev that provides this functionality... It works with (single value) text fields and textareas, but should be tested. I will not add this to cf 1.0, so we have time for testing.
Comment #2
peterpoe commentedCommitted to dev.