By jorje29 on
I'm trying to display an already built view with an argument which depended by an ahah form ( I use ahah helper ). In the example below, $group_nid is the argument and I pass it like this : views_embed_view($viewName, 'default', $group_nid). The problem is that I can't display both the ahah form AND the view. If I use " return $view_content; ", I can display the view. If I use " return $form; ", I can display the form. I need to display both. How can I achieve it ?
Thank you
function standings_form($form_state) {
$form = array();
// Register the form with ahah_helper so we can use it. Also updates
// $form_state['storage'] to ensure it contains the latest values that have
// been entered, even when the form item has temporarily been removed from
// the form. So if a form item *once* had a value, you *always* can retrieve
// it.
ahah_helper_register($form, $form_state);
// Determine the default value of the 'usage' select. When nothing is stored
// in $form_state['storage'] yet, it's the form hasn't been submitted yet,
// thus it's the first time the form is being displayed. Then, we set the
// default to 'company'.
if (!isset($form_state['storage']['groupset']['dropdown'])) {
$group_nid = 3;
}
else {
$group_nid = $form_state['storage']['groupset']['dropdown'];
}
$form['groupset'] = array(
'#type' => 'fieldset',
'#title' => t(''),
'#prefix' => '<div id="group-wrapper">', // This is our wrapper div.
'#suffix' => '</div>',
'#tree' => TRUE, // Don't forget to set #tree!
);
$form['groupset']['dropdown'] = array(
'#type' => 'select',
'#title' => t('Όμιλος'),
'#options' => array(
'1' => t('group 1'),
'2' => t('group 2'),
'3' => t('group 3'),
),
'#default_value' => $group_nid,
'#prefix' => '<div class="clear-block">',
'#suffix' => '</div>',
'#ahah' => array(
'event' => 'change',
// This is the "magical path". Note that the parameter is an array of
// the parents of the form item of the wrapper div!
'path' => ahah_helper_path(array('groupset')),
'wrapper' => 'group-wrapper',
),
);
$form['groupset']['update_usage'] = array(
'#type' => 'submit',
'#value' => t('Update usage'),
// Note that we can simply use the generic submit callback provided by the
// ahah_helper module here!
// All it does, is set $form_state['rebuild'] = TRUE.
'#submit' => array('ahah_helper_generic_submit'),
// We set the 'no-js' class, which means this submit button will be hidden
// automatically by Drupal if JS is enabled.
'#attributes' => array('class' => 'no-js'),
);
$view_content = $form;
$viewName = 'league_standings';
$view_content .= views_embed_view($viewName, 'default', $group_nid);
return $view_content;
}