You are here

function form_type_icon_selector_value in Icon API 8

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

Implements form_type_ELEMENT_value().

Value callback for the 'icon_selector' element.

File

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

Code

function form_type_icon_selector_value(&$element, $input = FALSE, &$form_state = array()) {
  if ($input !== FALSE && isset($input['icon']) && strpos($input['icon'], '|') !== FALSE) {
    list($bundle, $icon) = explode('|', $input['icon']);
    $wrapper = !empty($input['wrapper']) && in_array($input['wrapper'], array_keys(icon_wrapper_options())) ? $input['wrapper'] : '';
    $wrapper_class = !empty($input['wrapper_class']) ? \Drupal\Component\Utility\Xss::filterAdmin($input['wrapper_class']) : '';
    \Drupal\Component\Utility\NestedArray::setValue($form_state['values'], array_merge($element['#parents'], array(
      'bundle',
    )), $bundle, TRUE);
    \Drupal\Component\Utility\NestedArray::setValue($form_state['values'], array_merge($element['#parents'], array(
      'icon',
    )), $icon, TRUE);
    \Drupal\Component\Utility\NestedArray::setValue($form_state['values'], array_merge($element['#parents'], array(
      'wrapper',
    )), $wrapper, TRUE);
    \Drupal\Component\Utility\NestedArray::setValue($form_state['values'], array_merge($element['#parents'], array(
      'wrapper_class',
    )), $wrapper_class, TRUE);
  }
}