function theme_webform_view_embedded in Webform view 7.4
Same name and namespace in other branches
- 7 webform_view.inc \theme_webform_view_embedded()
Render the embedded view element in the form.
Most content has now been prepared and the child items rendered. My job is to MOVE the rendered form element markup and embed it into the view displays where the placeholders are.
1 theme call to theme_webform_view_embedded()
- _webform_render_view in ./
webform_view.inc - Show the embedded view on the webform.
File
- ./
webform_view.inc, line 364 - Additional component for webform that allows views to be used as embeddable elements.
Code
function theme_webform_view_embedded($variables) {
$element = $variables['element'];
// The rendered, already-built view is text in $element['view']['#markup'].
// The form elements are my direct children.
// Build an array of replacements for str_replace efficiency.
$replacements = array();
foreach (element_children($element) as $key) {
$replace_pattern = "[webform_view_" . $key . "_placeholder]";
// Child item has already been rendered/built by now. (#printed is true)
// Copy its processed text in here.
if (!empty($element[$key]['#printed'])) {
$rendered_child = $element[$key]['#children'];
}
else {
// Dunno why, but maybe I should render i myself.
// Used to be required, maybe this should never happen.
$rendered_child = drupal_render($element[$key]);
// TODO: check if this code is still reachable.
}
$replacements[$replace_pattern] = $rendered_child;
}
// I earlier placed the rendered view into $element['view']['#markup']
$element['view']['#markup'] = str_replace(array_keys($replacements), array_values($replacements), $element['view']['#markup']);
return $element['view']['#markup'];
}