hidden.inc in Webform 5
File
components/hidden.inc
View source
<?php
function _webform_edit_hidden($currfield) {
$edit_fields = array();
$edit_fields['value'] = array(
'#type' => 'textfield',
'#title' => t("Default value"),
'#default_value' => $currfield['default'],
'#description' => t('The default value of the field.') . '<br />' . webform_help('webform/helptext#variables'),
'#size' => 60,
'#maxlength' => 127,
'#weight' => 0,
);
$edit_fields['mandatory'] = array(
'#type' => 'hidden',
'#value' => 1,
);
$edit_fields['extra']['description'] = array();
return $edit_fields;
}
function _webform_render_hidden($component) {
$form_item = array(
'#type' => 'hidden',
'#value' => _webform_filtervalues($component['value']),
'#weight' => $component['weight'],
);
return $form_item;
}
function _webform_submission_display_hidden($data, $component, $enabled = false) {
$form_item = _webform_render_hidden($component);
$form_item['#value'] = $data['value']['0'];
$form_item['#type'] = 'textfield';
$form_item['#title'] = htmlspecialchars($component['name'], ENT_QUOTES) . " (hidden)";
$form_item['#disabled'] = !$enabled;
return $form_item;
}
function _webform_help_hidden($section) {
switch ($section) {
case 'admin/settings/webform#hidden_description':
$output = t("Create a field which is not visible to the user, but is recorded with the submission.");
break;
}
return $output;
}
function _webform_analysis_rows_hidden($component) {
$query = 'SELECT data ' . ' FROM {webform_submitted_data} ' . ' WHERE nid = %d ' . ' AND cid = %d';
$nonblanks = 0;
$submissions = 0;
$wordcount = 0;
$result = db_query($query, $component['nid'], $component['cid']);
while ($data = db_fetch_array($result)) {
if (strlen(trim($data['data'])) > 0) {
$nonblanks++;
$wordcount += str_word_count(trim($data['data']));
}
$submissions++;
}
$rows[0] = array(
t('Empty'),
$submissions - $nonblanks,
);
$rows[1] = array(
t('Non-empty'),
$nonblanks,
);
$rows[2] = array(
t('Average submission length in words (ex blanks)'),
$nonblanks != 0 ? number_format($wordcount / $nonblanks, 2) : '0',
);
return $rows;
}
function _webform_table_data_hidden($data) {
return check_plain(empty($data['value']['0']) ? "" : $data['value']['0']);
}
function _webform_csv_headers_hidden($component) {
$header = array();
$header[0] = '';
$header[1] = '';
$header[2] = $component['name'];
return $header;
}
function _webform_csv_data_hidden($data) {
return empty($data['value']['0']) ? "" : $data['value']['0'];
}
Functions
Name |
Description |
_webform_analysis_rows_hidden |
Calculate and returns statistics about results for this component from all
submission to this webform. The output of this function will be displayed
under the "results" tab then "analysis". |
_webform_csv_data_hidden |
Return the result of a textfield submission. The output of this function will
be displayed under the "results" tab then "submissions". |
_webform_csv_headers_hidden |
Return the header information for this component to be displayed in a comma
seperated value file. The output of this function will be displayed under the
"results" tab then "download". |
_webform_edit_hidden |
Create a set of form items to be displayed on the form for editing this
component. Use care naming the form items, as this correlates directly to the
database schema. The component "Name" and "Description" fields are added to
every… |
_webform_help_hidden |
Module specific instance of hook_help |
_webform_render_hidden |
Build a form item array containing all the properties of this component. |
_webform_submission_display_hidden |
Display the result of a textfield submission. The output of this function
will be displayed under the "results" tab then "submissions". |
_webform_table_data_hidden |
Return the result of this component's submission for display in a table. The
output of this function will be displayed under the "results" tab then "table". |