You are here

function _icon_states_selector in Icon API 8

Same name and namespace in other branches
  1. 7 includes/element.inc \_icon_states_selector()

Generates a #states selector to be used.

Parameters

string $key: The target element.

array $element: The relevant element, if any.

Return value

string A constructed #states selector.

File

includes/element.inc, line 41
element.inc Provides hooks and functions for element related tasks.

Code

function _icon_states_selector($key, array $element = NULL) {
  if (isset($element) && ($keys = isset($element['#parents']) ? $element['#parents'] : array())) {
    $keys[] = $key;
    $first = array_shift($keys);
    return ':input[name="' . $first . '[' . implode('][', $keys) . ']' . '"]';
  }
  return ':input[name="' . $key . '"]';
}