accordion_container.inc in Webform Accordion 6
Same filename and directory in other branches
Defines the Accordion Container webform component.
File
components/accordion_container.incView source
<?php
/**
* @file
* Defines the Accordion Container webform component.
*/
/**
* Implements _webform_defaults_component().
*/
function _webform_defaults_accordion_grp() {
return array(
'name' => '',
'form_key' => NULL,
'pid' => 0,
'weight' => 0,
'extra' => array(
'title_display' => 0,
'description' => '',
'private' => FALSE,
),
);
}
/**
* Implements _webform_edit_component().
*/
function _webform_edit_accordion_grp($component) {
$form = array();
return $form;
}
/**
* Implements _webform_render_component().
*/
function _webform_render_accordion_grp($component, $value = NULL, $filter = TRUE) {
$component['weight'] += 10;
$class = 'webform-component-' . str_replace('_', '-', $component['type']) . ' accordion';
$element = array(
'#type' => $component['type'],
'#title' => $filter ? _webform_filter_xss($component['name']) : $component['name'],
'#title_display' => $component['extra']['title_display'] ? $component['extra']['title_display'] : NULL,
'#weight' => $component['weight'],
'#description' => $filter ? _webform_filter_descriptions($component['extra']['description']) : $component['extra']['description'],
'#attributes' => array(
'class' => $class,
),
'#pre_render' => array(
'webform_element_title_display',
),
'#webform_component' => $component,
// ID's are made unique in hook_form_alter().
'#id' => 'webform-component-' . str_replace('_', '-', $component['type']),
);
return $element;
}
/**
* Pre-render function to set a accordion ID.
*/
function webform_accordion_grp_prerender($element) {
$element['#attributes']['id'] = 'webform-component-' . str_replace('_', '-', implode('--', array_slice($element['#parents'], 1)));
return $element;
}
/**
* Implements _webform_display_component().
*/
function _webform_display_accordion_grp($component, $value, $format = 'html') {
if ($format == 'text') {
$element = array(
'#title' => $component['name'],
'#weight' => $component['weight'],
'#post_render' => array(
'webform_element_wrapper',
),
'#theme_wrappers' => array(
'webform_element_text',
),
'#translatable' => array(
'title',
),
);
}
else {
$element = _webform_render_accordion_grp($component, $value);
}
$element['#format'] = $format;
return $element;
}
/**
* Module specific instance of hook_theme().
*
* This allows each Webform component to add information into hook_theme().
*/
function _webform_theme_accordion_grp() {
return array(
'accordion_grp' => array(
'arguments' => array(
'element' => NULL,
),
'file' => 'accordion_container.inc',
'path' => drupal_get_path('module', 'webform_accordion') . '/components',
),
);
}
/**
* Theme callback for rendering a single accordion tab.
*
* @param array $element
* The accordion tab element being rendered.
*
* @return string
* The HTML output for the tab.
*/
function theme_accordion_grp($element) {
webform_accordion_insert_js_css();
$content = !empty($element['#children']) ? $element['#children'] : '';
return theme('webform_accordion_container', $element['#attributes']['id'], $content, $element);
}
Functions
Name![]() |
Description |
---|---|
theme_accordion_grp | Theme callback for rendering a single accordion tab. |
webform_accordion_grp_prerender | Pre-render function to set a accordion ID. |
_webform_defaults_accordion_grp | Implements _webform_defaults_component(). |
_webform_display_accordion_grp | Implements _webform_display_component(). |
_webform_edit_accordion_grp | Implements _webform_edit_component(). |
_webform_render_accordion_grp | Implements _webform_render_component(). |
_webform_theme_accordion_grp | Module specific instance of hook_theme(). |