You are here

public static function FormHelper::rewriteStatesSelector in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Form/FormHelper.php \Drupal\Core\Form\FormHelper::rewriteStatesSelector()

Rewrite #states selectors.

Parameters

array $elements: A renderable array element having a #states property.

string $search: A partial or entire jQuery selector string to replace in #states.

string $replace: The string to replace all instances of $search with.

See also

drupal_process_states()

3 calls to FormHelper::rewriteStatesSelector()
Field::buildOptionsForm in core/modules/views/src/Plugin/views/field/Field.php
Default options form that provides the label widget that all fields should have.
FilterPluginBase::buildExposedFiltersGroupForm in core/modules/views/src/Plugin/views/filter/FilterPluginBase.php
Build the form to let users create the group of exposed filters. This form is displayed when users click on button 'Build group'
FormHelperTest::testRewriteStatesSelector in core/tests/Drupal/Tests/Core/Form/FormHelperTest.php
Tests rewriting the #states selectors.

File

core/lib/Drupal/Core/Form/FormHelper.php, line 31
Contains \Drupal\Core\Form\FormHelper.

Class

FormHelper
Provides helpers to operate on forms.

Namespace

Drupal\Core\Form

Code

public static function rewriteStatesSelector(array &$elements, $search, $replace) {
  if (!empty($elements['#states'])) {
    foreach ($elements['#states'] as $state => $ids) {
      static::processStatesArray($elements['#states'][$state], $search, $replace);
    }
  }
  foreach (Element::children($elements) as $key) {
    static::rewriteStatesSelector($elements[$key], $search, $replace);
  }
}