You are here

function finder_onoff_element in Finder 7.2

Element callback.

File

plugins/element_handler/onoff.inc, line 53
The finder on/off plugin handler.

Code

function finder_onoff_element($element, &$form_element, $form_state) {
  $finder = $element->finder;
  $properties = array();
  $form_element['#type'] = 'checkbox';
  $properties = array(
    'return_value',
  );
  if (isset($properties)) {
    foreach ($properties as $property) {
      $form_element['#' . $property] = $finder
        ->esetting($element, $property);
    }
  }
  $finder->find = array(
    'mode' => 'choices',
    'keywords' => array(
      $element->id => array(
        NULL,
      ),
    ),
    'element' => $element,
  );
  $finder
    ->find();
  $form_element['#options'] = !empty($finder->find['results']) ? $finder->find['results'] : array();
  if ($finder
    ->esetting($element, 'empty')) {
    $empty = array(
      '' => $finder
        ->esetting($element, 'empty_text'),
    );
    if ($finder
      ->esetting($element, 'empty') == 'prepend') {
      $form_element['#options'] = $empty + $form_element['#options'];
    }
    elseif ($finder
      ->esetting($element, 'empty') == 'append') {
      $form_element['#options'] = $form_element['#options'] + $empty;
    }
  }
}