From 590cd7b050c231e542b3a5e316ea711413f8b629 Mon Sep 17 00:00:00 2001 From: Sandip Shirsale Date: Thu, 26 May 2016 09:33:51 +0530 Subject: [PATCH] Issue #2674410 by sandip.shirsale: Added a valid condition before execution. --- conditional_fields.module | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/conditional_fields.module b/conditional_fields.module index 5b50edd..39a23c9 100644 --- a/conditional_fields.module +++ b/conditional_fields.module @@ -1821,8 +1821,10 @@ function conditional_fields_states_handler_text($field, $field_info, $options, & // TODO: support multiple values. if ($options['values_set'] == CONDITIONAL_FIELDS_DEPENDENCY_VALUES_WIDGET) { // Cast as array to handle the exception of autocomplete text fields. - $value = (array) $state[$options['state']][$options['selector']]['value'][0]; - $state[$options['state']][$options['selector']]['value'] = array_shift($value); + if($state[$options['state']][$options['selector']]['value'][0]){ + $value = (array) $state[$options['state']][$options['selector']]['value'][0]; + $state[$options['state']][$options['selector']]['value'] = array_shift($value); + } } } @@ -1853,12 +1855,12 @@ function conditional_fields_states_handler_date_combo($field, $field_info, $opti // Date popup. if ($field_info['instance']['widget']['type'] == 'date_popup') { $date_selectors[conditional_fields_field_selector($field['value']['date'])] = array( - 'value' => $regex ? $options['value'] : $options['value_form'][0]['value']['date'], + 'value' => $regex ? $options['value'] : ($options['value_form'][0]['value']['date'] ? $options['value_form'][0]['value']['date'] : ''), ); if ($field_info['field']['settings']['granularity']['hour'] || $field_info['field']['settings']['granularity']['minute'] || $field_info['field']['settings']['granularity']['second']) { $date_selectors[conditional_fields_field_selector($field['value']['time'])] = array( - 'value' => $regex ? $options['value'] : $options['value_form'][0]['value']['time'], + 'value' => $regex ? $options['value'] : ($options['value_form'][0]['value']['time'] ? $options['value_form'][0]['value']['time'] : ''), ); } } @@ -1867,7 +1869,7 @@ function conditional_fields_states_handler_date_combo($field, $field_info, $opti foreach ($field_info['field']['settings']['granularity'] as $date_part) { if ($date_part) { $date_selectors[conditional_fields_field_selector($field['value'][$date_part])] = array( - 'value' => $regex ? $options['value'] : $options['value_form'][0]['value'][$date_part], + 'value' => $regex ? $options['value'] : ($options['value_form'][0]['value'][$date_part] ? $options['value_form'][0]['value'][$date_part]: ''), ); } } -- 1.9.4.msysgit.1