You are here

protected function ConditionalFieldsFormHelper::addStateToGroup in Conditional Fields 4.x

Same name and namespace in other branches
  1. 8 src/ConditionalFieldsFormHelper.php \Drupal\conditional_fields\ConditionalFieldsFormHelper::addStateToGroup()

Merge field states to general list.

Parameters

array $new_states: List of new states to add to the existing states.

array $options: Field CF settings.

array $states: An array of existing states.

Return value

array An array of modified states.

1 call to ConditionalFieldsFormHelper::addStateToGroup()
ConditionalFieldsFormHelper::processDependeeFields in src/ConditionalFieldsFormHelper.php
Determine and register dependee field effects.

File

src/ConditionalFieldsFormHelper.php, line 323

Class

ConditionalFieldsFormHelper
Helper to interact with forms.

Namespace

Drupal\conditional_fields

Code

protected function addStateToGroup(array $new_states, array $options, array $states) {

  // Add the $state into the correct logic group in $states.
  foreach ($new_states as $key => $constraints) {
    if (empty($states[$key][$options['grouping']])) {
      $states[$key][$options['grouping']] = $constraints;
    }
    else {
      $states[$key][$options['grouping']] = array_merge($states[$key][$options['grouping']], $constraints);
    }
  }
  return $states;
}