You are here

function form_builder_get_form_type in Form Builder 6

Get a list of all properties that are supported by a particular form type.

6 calls to form_builder_get_form_type()
form_builder_add_default_properties in includes/form_builder.api.inc
Helper function to add default #form_builder properties to a form.
form_builder_field_palette in includes/form_builder.admin.inc
Render the palette of fields to add to a form.
form_builder_get_element_properties in includes/form_builder.api.inc
Given an element type, return properties that are supported by Form builder.
form_builder_get_saveable_properties in includes/form_builder.api.inc
Get a list of properties that are supported in any way by an element.
form_builder_menu_field_access in ./form_builder.module
Access callback for field configuration, viewing, addition, and deletion.

... See full list

File

includes/form_builder.api.inc, line 32
form_builder.api.inc Universally used API functions within the Form builder module.

Code

function form_builder_get_form_type($form_type = NULL, $reset = FALSE) {
  static $types;
  if (!isset($types) || $reset) {
    $types = array();

    // Get the list of all properties for all elements.
    $types = module_invoke_all('form_builder_types');

    // Add default values for undefined properties.
    foreach ($types as $type_key => &$type) {
      $groups = module_invoke_all('form_builder_palette_groups', $type_key);
      foreach ($type as $field_key => &$field) {
        $field['unique'] = isset($field['unique']) && $field['unique'];
        $field['configurable'] = isset($field['configurable']) ? $field['configurable'] : TRUE;
        $field['removable'] = isset($field['removable']) ? $field['removable'] : TRUE;
        $field['addable'] = isset($field['addable']) ? $field['addable'] : $field['removable'] && isset($field['default']);
        $field['palette_group'] = isset($field['palette_group']) && isset($groups[$field['palette_group']]) ? $field['palette_group'] : 'default';
        $field['properties'] = isset($field['properties']) ? $field['properties'] : array();

        // All fields must support weight.
        if (!in_array('weight', $field['properties'])) {
          $field['properties'][] = 'weight';
        }

        // Update the default elements with some defaults.
        // Note that if a field is not removable, it doesn't have a default.
        if ($field['addable']) {
          if ($field['unique']) {
            $field['default']['#form_builder']['element_id'] = $field_key;
            if (!isset($field['default']['#form_builder']['element_type'])) {
              $field['default']['#form_builder']['element_type'] = $field_key;
            }
          }
          elseif (!isset($field['default']['#form_builder']['element_type'])) {
            $field['default']['#form_builder']['element_type'] = $field_key;
          }
        }
      }

      // Sort fields by weight and title.
      uasort($type, '_form_builder_sort');
    }
    drupal_alter('form_builder_types', $types);
  }
  return isset($form_type) ? $types[$form_type] : $types;
}