You are here

protected static function ConditionalFieldsFormHelper::getEffect in Conditional Fields 8

Same name and namespace in other branches
  1. 4.x src/ConditionalFieldsFormHelper.php \Drupal\conditional_fields\ConditionalFieldsFormHelper::getEffect()

Returns js effect for field.

Parameters

array $options: Field CF settings.

Return value

array Effect with options.

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

File

src/ConditionalFieldsFormHelper.php, line 286

Class

ConditionalFieldsFormHelper
Helper to interact with forms.

Namespace

Drupal\conditional_fields

Code

protected static function getEffect($options) {

  // Build effect settings for effects with options.
  // TODO: add dependee key to allow different effects on the same selector.
  if ($options['effect'] && $options['effect'] != 'show') {

    // Convert numeric strings to numbers.
    foreach ($options['effect_options'] as &$effect_option) {
      if (is_numeric($effect_option)) {
        $effect_option += 0;
      }
    }
    return [
      'effect' => $options['effect'],
      'options' => $options['effect_options'],
    ];
  }
  return [];
}