Ejemplo n.º 1
0
/**
 * Render a Webform component to be part of a form.
 *
 * @param $component
 *   A Webform component array.
 * @param $value
 *   If editing an existing submission or resuming a draft, this will contain
 *   an array of values to be shown instead of the default in the component
 *   configuration. This value will always be an array, keyed numerically for
 *   each value saved in this field.
 * @param $filter
 *   Whether or not to filter the contents of descriptions and values when
 *   rendering the component. Values need to be unfiltered to be editable by
 *   Form Builder.
 *
 * @see _webform_client_form_add_component()
 */
function _webform_render_component($component, $value = NULL, $filter = TRUE)
{
    $form_item = array('#type' => 'textfield', '#title' => $filter ? webform_filter_xss($component['name']) : $component['name'], '#required' => $component['required'], '#weight' => $component['weight'], '#description' => $filter ? webform_filter_descriptions($component['extra']['description']) : $component['extra']['description'], '#default_value' => $filter ? webform_replace_tokens($component['value']) : $component['value'], '#prefix' => '<div class="webform-component-textfield" id="webform-component-' . $component['form_key'] . '">', '#suffix' => '</div>');
    if (isset($value)) {
        $form_item['#default_value'] = $value[0];
    }
    return $form_item;
}
Ejemplo n.º 2
0
/**
 * Render a Webform component to be part of a form.
 *
 * @param $component
 *   A Webform component array.
 * @param $value
 *   If editing an existing submission or resuming a draft, this will contain
 *   an array of values to be shown instead of the default in the component
 *   configuration. This value will always be an array, keyed numerically for
 *   each value saved in this field.
 * @param $filter
 *   Whether or not to filter the contents of descriptions and values when
 *   rendering the component. Values need to be unfiltered to be editable by
 *   Form Builder.
 * @param $submission
 *   The submission from which this component is being rendered. Usually not
 *   needed. Used by _webform_render_date() to validate using the submission's
 *   completion date.
 *
 * @see _webform_client_form_add_component()
 */
function _webform_render_component($component, $value = NULL, $filter = TRUE, $submission = NULL)
{
    $form_item = array('#type' => 'textfield', '#title' => $filter ? webform_filter_xss($component['name']) : $component['name'], '#required' => $component['required'], '#weight' => $component['weight'], '#description' => $filter ? webform_filter_descriptions($component['extra']['description']) : $component['extra']['description'], '#default_value' => $filter ? webform_replace_tokens($component['value']) : $component['value'], '#theme_wrappers' => array('webform_element'));
    if (isset($value)) {
        $form_item['#default_value'] = $value[0];
    }
    return $form_item;
}