You are here

function form_builder_field_render in Form Builder 6

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

Render a single field independent of other settings.

2 calls to form_builder_field_render()
form_builder_field_json in includes/form_builder.admin.inc
Menu callback to display a field as a JSON string.
_form_builder_add_element in includes/form_builder.admin.inc
Menu callback helper for adding or cloning a field.

File

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

Code

function form_builder_field_render($form_type, $form_id, $element_id, $wrapper = FALSE) {
  module_load_include('inc', 'form_builder', 'includes/form_builder.api');
  module_load_include('inc', 'form_builder', 'includes/form_builder.cache');

  // Load the current state of the form and prepare it for rendering.
  $form = form_builder_cache_load($form_type, $form_id);
  $form_state = array(
    'submitted' => FALSE,
  );
  $form = drupal_retrieve_form('form_builder_preview', $form_state, $form, $form_type, $form_id);
  drupal_prepare_form('form_builder_preview', $form, $form_state);
  $form['#post'] = array();
  $form = form_builder('form_builder_preview', $form, $form_state);

  // Get only the element wanted and render it.
  $element = form_builder_get_element($form, $element_id);
  if ($wrapper) {
    $element['#form_builder_wrappers'][] = 'form_builder_element_wrapper';
    $element['#post_render'][] = 'form_builder_wrappers';
  }
  return drupal_render($element);
}