Hi, all.

The drupal_render function
here is the quotation from the documentation
http://api.drupal.org/api/function/drupal_render/6
--
Renders HTML given a structured array tree.

Recursively iterates over each of the array elements, generating HTML code. This function is usually called from within a another function, like drupal_get_form() or node_view().
--

The function recieves the "$elements The structured array describing the data to be rendered."
The Array can be nested. In this way the function may to render the structure with free depth of nesting.

The Array of the upper level is a some kind of container for the sub array elements.
Before the container rendering, at first sequentially the functions are called for rendering for all his children.
The rendering results of children is concatenated in one line
/* render each of the children using drupal_render and concatenate them */
[child-1].[child-2].[child-3].---.[child-N]
after what the container adds his data and on the exit we receive the line of the following view:
[container-start][child-1].[child-2].[child-3].---.[child-N].[container-end]

The question is.
Is it possible to insert the separates between children?
I mean is it possible to receive in the result the line of the following view:
[container-start][child-1].[container-separator].[child-2].[container-separator].[child-3].[container-separator]---[container-separator].[child-N].[container-end]

for instance, let in the role of container will be the form and fieldset
the form rendering result will be the following
[table]
[tr][td]Label1[/td][td]input1[/td][/tr]
[tr][td]Label2[/td][td]input2[/td][/tr]
[tr][td]Label2[/td][td]input2[/td][/tr]
[/table]

We could not implement that only by means of interception of theme hooks. Namely the button rendering has not came through.

Actually the issue is more global the just the form rendering.
Is there exists in the current rendering system such a notion, as the container template?
As, the usual concatenate is extremely inconvenient.

Best regards.

Comments

savel’s picture

Status: Active » Needs review

It's not clear from documentation, it's not clear at all... Most of questions simillar to yours remain unanswered. but...

i've spent a night with googling, digging in drupal docs and code, than i've found a solution:

At first: register a hook for elements theming.

/**
 * Implementation of hook_theme().
 */
function bmcustoms_theme() {
  return array(
    'uc_bmcustoms_theme_checkboxes' => array(
      'arguments' => array('checkboxes' => NULL),
      ),
    );
}

second (and most important part!) define a theming function:

function theme_uc_bmcustoms_theme_checkboxes($checkboxes){
$output = '';
foreach (element_children($checkboxes) as $option){
	$output .= '<td>';
	$output .= drupal_render($checkboxes[$option]);
	$output .= '</td>';
}
return $output;
}

It worked for me, but I believe for common use it's better to replace html markup with $checkboxes['#prefix'] and $checkboxes['#suffix'], or kind of this.

And finally we should add '#theme' property for our element and call drupal_render for it where we like it to be rendered.

$form[$aid]['#theme']='uc_bmcustoms_theme_checkboxes';
$output .= drupal_render($form[$aid]); 

Hope it could help to someone! Cheers!

damien tournoud’s picture

Category: feature » support
Status: Needs review » Closed (won't fix)

The issue queue is not appropriate for support request or code snippet exchange. Please use the forum instead.