/** * Theme override for theme_webform_element(). */ function codedotorg_webform_element($variables) { // Ensure defaults. $variables['element'] += array('#title_display' => 'before'); $element = $variables['element']; // All elements using this for display only are given the "display" type. if (isset($element['#format']) && $element['#format'] == 'html') { $type = 'display'; } else { $type = isset($element['#type']) && !in_array($element['#type'], array('markup', 'textfield', 'webform_email', 'webform_number')) ? $element['#type'] : $element['#webform_component']['type']; } // Convert the parents array into a string, excluding the "submitted" wrapper. $nested_level = $element['#parents'][0] == 'submitted' ? 1 : 0; $parents = str_replace('_', '-', implode('--', array_slice($element['#parents'], $nested_level))); $wrapper_classes = array('form-item', 'webform-component', 'webform-component-' . $type); /* CUSTOMIZATION FOR CODE.ORG */ if (in_array($element['#webform_component']['nid'], array(91, 92, 124)) || current_path() == 'node/27') { $wrapper_classes[] = 'control-group'; $element['#children'] = '<div class="controls">' . $element['#children'] . '</div>'; } /* END CUSTOMIZATION FOR CODE.ORG */ if (isset($element['#title_display']) && strcmp($element['#title_display'], 'inline') === 0) { $wrapper_classes[] = 'webform-container-inline'; } $output = '<div class="' . implode(' ', $wrapper_classes) . '" id="webform-component-' . $parents . '">' . "\n"; // If #title is not set, we don't display any label or required marker. if (!isset($element['#title'])) { $element['#title_display'] = 'none'; } $prefix = isset($element['#field_prefix']) ? '<span class="field-prefix">' . _webform_filter_xss($element['#field_prefix']) . '</span> ' : ''; $suffix = isset($element['#field_suffix']) ? ' <span class="field-suffix">' . _webform_filter_xss($element['#field_suffix']) . '</span>' : ''; switch ($element['#title_display']) { case 'inline': case 'before': case 'invisible': $output .= ' ' . theme('form_element_label', $variables); $output .= ' ' . $prefix . $element['#children'] . $suffix . "\n"; break; case 'after': $output .= ' ' . $prefix . $element['#children'] . $suffix; $output .= ' ' . theme('form_element_label', $variables) . "\n"; break; case 'none': case 'attribute': // Output no label and no required marker, only the children. $output .= ' ' . $prefix . $element['#children'] . $suffix . "\n"; break; } if (!empty($element['#description'])) { $output .= ' <div class="description">' . $element['#description'] . "</div>\n"; } $output .= "</div>\n"; return $output; }
/** * 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['mandatory'], '#weight' => $component['weight'], '#description' => $filter ? _webform_filter_descriptions($component['extra']['description']) : $component['extra']['description'], '#default_value' => $filter ? _webform_filter_values($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; }
/** * Overwrite theme_webform_element(). */ function bht_theme_webform_element($variables) { // Ensure defaults. $variables['element'] += array('#title_display' => 'before'); $element = $variables['element']; $output = '<div class="' . $variables['element']['#webform_component']['form_key'] . '">' . "\n"; // If #title is not set, we don't display any label or required marker. if (!isset($element['#title'])) { $element['#title_display'] = 'none'; } $prefix = isset($element['#field_prefix']) ? '<span>' . _webform_filter_xss($element['#field_prefix']) . '</span> ' : ''; $suffix = isset($element['#field_suffix']) ? ' <span>' . _webform_filter_xss($element['#field_suffix']) . '</span>' : ''; switch ($element['#title_display']) { case 'inline': case 'before': case 'invisible': $output .= ' ' . theme('form_element_label', $variables); $output .= ' ' . $prefix . $element['#children'] . $suffix . "\n"; break; case 'after': $output .= ' ' . $prefix . $element['#children'] . $suffix; $output .= ' ' . theme('form_element_label', $variables) . "\n"; break; case 'none': case 'attribute': // Output no label and no required marker, only the children. $output .= ' ' . $prefix . $element['#children'] . $suffix . "\n"; break; } if (!empty($element['#description'])) { $output .= ' <small>' . $element['#description'] . "</small>\n"; } $output .= "</div>\n"; return $output; }
/** * Theme webform eleemnts */ function traveljordan_webform_element($variables) { $variables['element'] += array('#title_display' => 'before'); $element = $variables['element']; if (isset($element['#format']) && $element['#format'] == 'html') { $type = 'display'; } else { $type = isset($element['#type']) && !in_array($element['#type'], array('markup', 'textfield', 'webform_email', 'webform_number')) ? $element['#type'] : $element['#webform_component']['type']; } $nested_level = $element['#parents'][0] == 'submitted' ? 1 : 0; $parents = str_replace('_', '-', implode('--', array_slice($element['#parents'], $nested_level))); $wrapper_classes = array('form-group', 'form-item', 'webform-component', 'webform-component-' . $type); if (isset($element['#container_class'])) { $wrapper_classes[] = $element['#container_class']; } if (isset($element['#title_display']) && strcmp($element['#title_display'], 'inline') === 0) { $wrapper_classes[] = 'webform-container-inline'; } $output = '<div class="' . implode(' ', $wrapper_classes) . '" id="webform-component-' . $parents . '">' . "\n"; if (!isset($element['#title'])) { $element['#title_display'] = 'none'; } $prefix = isset($element['#field_prefix']) ? '<span class="field-prefix">' . _webform_filter_xss($element['#field_prefix']) . '</span> ' : ''; $suffix = isset($element['#field_suffix']) ? ' <span class="field-suffix">' . _webform_filter_xss($element['#field_suffix']) . '</span>' : ''; switch ($element['#title_display']) { case 'inline': case 'before': case 'invisible': $output .= ' ' . theme('form_element_label', $variables); $output .= ' ' . $prefix . $element['#children'] . $suffix . "\n"; break; case 'after': $output .= ' ' . $prefix . $element['#children'] . $suffix; $output .= ' ' . theme('form_element_label', $variables) . "\n"; break; case 'none': case 'attribute': $output .= ' ' . $prefix . $element['#children'] . $suffix . "\n"; break; } if (!empty($element['#description'])) { $output .= ' <div class="description">' . $element['#description'] . "</div>\n"; } $output .= "</div>\n"; return $output; }
/** * Remove wrappers from markup elements. */ function k373k_webform_element($variables) { // Ensure defaults. $variables['element'] += array( '#title_display' => 'before', ); $element = $variables['element']; // All elements using this for display only are given the "display" type. if (isset($element['#format']) && $element['#format'] == 'html') { $type = 'display'; } else { $type = (isset($element['#type']) && !in_array($element['#type'], array('markup', 'textfield'))) ? $element['#type'] : $element['#webform_component']['type']; } $parents = str_replace('_', '-', implode('--', array_slice($element['#parents'], 1))); $wrapper_classes = array( 'form-item', 'webform-component', 'webform-component-' . $type, ); if (isset($element['#title_display']) && $element['#title_display'] == 'inline') { $wrapper_classes[] = 'webform-container-inline'; } if ($element['#type'] != 'markup') { $output = '<div class="' . implode(' ', $wrapper_classes) . '" id="webform-component-' . $parents . '">' . "\n"; } else { $output = ''; } $required = !empty($element['#required']) ? '<span class="form-required" title="' . t('This field is required.') . '">*</span>' : ''; // If #title is not set, we don't display any label or required marker. if (!isset($element['#title'])) { $element['#title_display'] = 'none'; } $prefix = isset($element['#field_prefix']) ? '<span class="field-prefix">' . _webform_filter_xss($element['#field_prefix']) . '</span> ' : ''; $suffix = isset($element['#field_suffix']) ? ' <span class="field-suffix">' . _webform_filter_xss($element['#field_suffix']) . '</span>' : ''; switch ($element['#title_display']) { case 'inline': case 'before': case 'invisible': $output .= ' ' . theme('form_element_label', $variables); $output .= ' ' . $prefix . $element['#children'] . $suffix . "\n"; break; case 'after': $output .= ' ' . $prefix . $element['#children'] . $suffix; $output .= ' ' . theme('form_element_label', $variables) . "\n"; break; case 'none': case 'attribute': // Output no label and no required marker, only the children. $output .= ' ' . $prefix . $element['#children'] . $suffix . "\n"; break; } if (!empty($element['#description'])) { $output .= ' <div class="description">' . $element['#description'] . "</div>\n"; } if ($element['#type'] != 'markup') { $output .= "</div>\n"; } return $output; }