function form_builder_field_palette in Form Builder 7.2
Same name and namespace in other branches
- 6 includes/form_builder.admin.inc \form_builder_field_palette()
- 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 170 - 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)) {
$form_type = $active['form_type'];
$form_id = $active['form_id'];
$loader = Loader::instance();
$fields = $loader
->getElementTypeInfo($form_type, $form_id);
$groups = $loader
->getPaletteGroupInfo($form_type, $form_id);
// TODO: We shouldn't have to clear the cache here.
$form = $loader
->fromCache($form_type, $active['form_id'], NULL, TRUE);
$active_fields = $form
->getElementTypes();
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', array(
'fields' => $fields,
'groups' => $groups,
'form_type' => $active['form_type'],
'form_id' => $active['form_id'],
));
}
return $output;
}