You are here

function finder_form_element in Finder 7.2

Get the form array for an element.

Parameters

$finder: A loaded finder object.

$element: The element object

$form_state: The form state. Should only use $form_state['values'] in this function because of finder_element_ajax().

Return value

The form element array.

2 calls to finder_form_element()
finder_element_ajax in ./finder.module
Menu callback; get finder ajax output.
finder_form in includes/form.inc
FAPI definition for the finder form.

File

includes/form.inc, line 227
The finder form.

Code

function finder_form_element(&$finder, &$element, &$form_state) {
  if (isset($form_state['values'][$element->id])) {
    $element_default = $form_state['values'][$element->id];
  }
  else {
    $element_default = $finder
      ->esetting($element, 'default_value');
    $finder->form_state['values'][$element->id] = $form_state['values'][$element->id] = $element_default;
  }
  $form_element = array(
    '#title' => check_plain($element->title),
    '#weight' => $element->weight,
    '#description' => check_markup($finder
      ->esetting($element, 'description')),
    '#default_value' => $element_default,
    '#required' => $finder
      ->esetting($element, 'required'),
    '#executes_submit_callback' => TRUE,
    '#field_prefix' => check_markup($finder
      ->esetting($element, 'field_prefix')),
    '#field_suffix' => check_markup($finder
      ->esetting($element, 'field_suffix')),
    '#title_display' => $finder
      ->esetting($element, 'title_display', 'before'),
    '#attributes' => array(
      'class' => array(
        'finder-element',
        'finder-element-' . $element->id,
      ),
    ),
  );
  $header = $finder
    ->esetting($element, 'header');
  $form_element['#prefix'] = '';
  if (!empty($header['value']) && isset($header['format'])) {
    $form_element['#prefix'] = check_markup($header['value'], $header['format'], FALSE);
  }
  $form_element['#prefix'] = '<div class="finder-form-element finder-form-element-' . $element->id . '">' . $form_element['#prefix'];
  $footer = $finder
    ->esetting($element, 'footer');
  $form_element['#suffix'] = '';
  if (!empty($footer['value']) && isset($footer['format'])) {
    $form_element['#suffix'] = check_markup($footer['value'], $footer['format'], FALSE);
  }
  $form_element['#suffix'] .= '</div>';
  if ($handler_function = ctools_plugin_get_function($element->element_handler, 'element callback')) {
    $handler_function($element, $form_element, $form_state);
  }
  return $form_element;
}