function theme_form_builder_field_palette in Form Builder 6
Same name and namespace in other branches
- 7.2 includes/form_builder.admin.inc \theme_form_builder_field_palette()
- 7 includes/form_builder.admin.inc \theme_form_builder_field_palette()
Block for adding new fields.
Parameters
$fields: A list of all fields can be added to the current form type.
$groups: A list of groups that fields may be sorted into. Each field is assigned a 'palette_group' property which corresponds to one of these groups.
$form_type: The form type to which these blocks apply.
$form_id: The form ID that is being edited.
1 theme call to theme_form_builder_field_palette()
- form_builder_field_palette in includes/
form_builder.admin.inc - Render the palette of fields to add to a form.
File
- includes/
form_builder.admin.inc, line 455 - form_builder.admin.inc Administrative interface for editing forms.
Code
function theme_form_builder_field_palette($fields, $groups, $form_type, $form_id) {
$output = '';
$lists = array();
foreach ($fields as $field_name => $field) {
$class = array(
'field-' . $field_name,
'form-builder-palette-element',
);
$style = '';
// If a field is unique, add a special class to identify it.
if ($field['unique']) {
$class[] = 'form-builder-unique';
$class[] = 'form-builder-element-' . $field_name;
// If already in use, do not display it in the list.
if (!empty($field['in_use'])) {
$style = 'display: none;';
}
}
$lists[$field['palette_group']]['#weight'] = $groups[$field['palette_group']]['weight'];
$lists[$field['palette_group']][] = array(
'data' => l($field['title'], 'admin/build/form-builder/add/' . $form_type . '/' . $form_id . '/' . $field_name, array(
'query' => drupal_get_destination(),
)),
'class' => implode(' ', $class),
'style' => $style,
);
}
// Sort the lists by weight.
uasort($lists, 'element_sort');
$output .= '<div id="form-builder-field-palette">';
foreach ($lists as $group => $list) {
unset($list['#weight']);
$output .= theme('item_list', $list, count($lists) > 1 ? $groups[$group]['title'] : t('Add a field'), 'ul', array(
'class' => 'form-builder-fields clear-block',
));
}
$output .= '</div>';
return $output;
}