function form_builder_preview in Form Builder 7
Same name and namespace in other branches
- 6 includes/form_builder.admin.inc \form_builder_preview()
- 7.2 includes/form_builder.admin.inc \form_builder_preview()
Form. Given a form array, present it for editing in a preview.
2 string references to 'form_builder_preview'
- form_builder_field_render in includes/
form_builder.admin.inc - Render a single field independent of other settings.
- form_builder_interface in includes/
form_builder.admin.inc - Main form building interface. Can be used as a menu callback.
File
- includes/
form_builder.admin.inc, line 195 - form_builder.admin.inc Administrative interface for editing forms.
Code
function form_builder_preview($f, &$form_state, $form_obj, $form_type, $form_id) {
// @todo: think about this more. We basically get the form from outside, so
// while normally the first argument would be $form, we use the third, which
// is provided by the caller.
// Make modifications to all form elements recursively.
$element_ids = $form_obj
->getElementIds();
$form = $form_obj
->preview();
// Record all the element IDs within the entire form.
$form['#form_builder']['element_ids'] = $element_ids;
$form['#form_builder']['form_type'] = $form_type;
$form['#form_builder']['form_id'] = $form_id;
// Add a pre_render to the entire form itself.
$form['#pre_render'][] = 'form_builder_pre_render_form';
$form['#theme_wrappers'] = array(
'form_builder_wrapper',
);
// Add required jQuery UI elements.
$form['#attached']['library'][] = array(
'system',
'ui.draggable',
);
$form['#attached']['library'][] = array(
'system',
'ui.droppable',
);
$form['#attached']['library'][] = array(
'system',
'ui.sortable',
);
$form['#attached']['library'][] = array(
'system',
'form',
);
$form['#attached']['js'][] = drupal_get_path('module', 'form_builder') . '/form_builder.js';
// TODO: This JS file should be loaded dynamically as needed.
$form['#attached']['js'][] = drupal_get_path('module', 'options_element') . '/options_element.js';
// TODO: Use libraries if available. see http://drupal.org/node/954804
$form['#attached']['js'][] = 'misc/tabledrag.js';
$form['#attached']['js'][] = 'misc/jquery.cookie.js';
$form['#attached']['library'][] = array(
'system',
'form',
);
$form['#attached']['js'][] = 'misc/form.js';
$form['#attached']['js'][] = 'misc/collapse.js';
$form['#attached']['js'][] = drupal_get_path('module', 'filter') . '/filter.js';
$form['#attached']['css'][] = drupal_get_path('module', 'filter') . '/filter.css';
$form['#attached']['js'][] = array(
'data' => array(
'machineName' => array(),
),
'type' => 'setting',
);
$form['#attached']['js'][] = 'misc/machine-name.js';
$settings = array(
'emptyForm' => theme('form_builder_empty_form'),
'emptyFieldset' => theme('form_builder_empty_fieldset'),
'noFieldSelected' => theme('form_builder_no_field_selected'),
'fieldLoading' => theme('form_builder_field_loading'),
);
$form['#attached']['js'][] = array(
'data' => array(
'formBuilder' => $settings,
),
'type' => 'setting',
);
$form['#attached']['css'][] = drupal_get_path('module', 'form_builder') . '/form_builder.css';
$form['#attached']['css'][] = drupal_get_path('module', 'options_element') . '/options_element.css';
return $form;
}