You are here

function form_builder_field_palette in Form Builder 6

Same name and namespace in other branches
  1. 7.2 includes/form_builder.admin.inc \form_builder_field_palette()
  2. 7 includes/form_builder.admin.inc \form_builder_field_palette()

Render the palette of fields to add to a form.

2 calls to form_builder_field_palette()
form_builder_block_view in ./form_builder.module
Implements hook_block_view().
theme_form_builder_wrapper in includes/form_builder.admin.inc
Output the wrapper around the form_builder preview.

File

includes/form_builder.admin.inc, line 187
form_builder.admin.inc Administrative interface for editing forms.

Code

function form_builder_field_palette() {
  $active = form_builder_active_form();
  $output = NULL;
  if (isset($active)) {
    $fields = form_builder_get_form_type($active['form_type']);
    $groups = module_invoke_all('form_builder_palette_groups');

    // TODO: We shouldn't have to clear the cache here.
    $form = form_builder_cache_load($active['form_type'], $active['form_id'], NULL, TRUE);
    $active_fields = form_builder_get_element_types($form);
    foreach ($fields as $key => $field) {
      if ($field['unique'] && in_array($key, $active_fields)) {
        $fields[$key]['in_use'] = TRUE;
      }
      if ($field['addable'] == FALSE) {
        unset($fields[$key]);
      }
    }
    $output = theme('form_builder_field_palette', $fields, $groups, $active['form_type'], $active['form_id']);
  }
  return $output;
}