Rendering a form together with other content into a Drupal 7 block -
i'm trying render block in module contains both form , list of links. can display 1 or other correctly, apparently not understand render array format enough them both rendered @ same time (one above other) in same block. using drupal 7.4
example setting block content show list:
$block['subject']='title'; $items= // code generates list of links array $theme_args=array('items'=>$items,'type'=>'ul'); $block['content']=theme('item_list',$theme_args); return $block;
example setting block content show form:
$block['subject']='title'; $block['content']=drupal_get_form('mymodule_myform_function'); // call function returns usual form array return $block;
each case works fine individually me. how can combine form , list 1 block['content'] array can rendered in 1 block? in advance.
i think should work, haven't tested though:
$block = array( 'items' = array( '#markup' => theme('item_list', $theme_args); ), 'form' = drupal_get_form('mymodule_myform_function'); ); $block['content'] = $block;
it little counter-intuitive, drupal_get_form
returns form render array, theme()
returns markup.
you (terrible solution) isn't advised highly inefficient , goes against drupal intends do:
$block['content'] = theme('item_list', $theme_args) . render(drupal_get_form('myform'));
Comments
Post a Comment