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.

CommentFileSizeAuthor
#1 conditional_fields_470968.patch1.35 KBpeterpoe

Comments

peterpoe’s picture

Version: 6.x-1.0-beta1 » 6.x-1.x-dev
Status: Active » Needs work
StatusFileSize
new1.35 KB

Here'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.

peterpoe’s picture

Version: 6.x-1.x-dev » 6.x-2.x-dev
Status: Needs work » Fixed

Committed to dev.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.