1

Basically, I have tabs on my modules admin page, I need to show a different form per page. The node type and forms have been created and the first form on block[0] shows correctly, while the first part of block[1] shows correctly, it also icludes some fields from block[0] and this shouldn't be so.

Here is my hook_block, maybe someone can spot my mistake and point it out to me.

function svm_mail_block($op = 'list', $delta = 0, $edit = array()) {

switch ($op) {
  case 'list':
    $blocks = array(
      0 => array(
        'info' => t('Add New Account'),
        'status' => 1,
        'region' => 'content',
        'visibility' => 1,
        'pages' => array('admin/settings/svm-mail/add-account'),           
        ),
      1 => array(
        'info' => t('Update Mail Statistics'),
        'status' => 1,
        'region' => 'content',
        'visibility' => 1,
        'pages' => array('admin/settings/svm-mail/ymlp/update'),
        )
      );
    return $blocks;
    break;

  case 'view':
    if(user_access('create mail account')) {
    switch ($delta) {
      case 0:
        //render node form from http://api.drupal.org/api/drupal/includes!form.inc/function/drupal_get_form/6
        module_load_include('inc', 'node', 'node.pages');
        $node_type = 'svm_mail_account';
        $form_id = $node_type . '_node_form';
        global $user;
        $node = new stdClass();
        $node ->uid = $user->uid;
        $node ->name = (isset($user->name) ? $user ->name: '');
        $node ->type = $node_type;
        $block['subject'] = t('Add New Account');
        $block['content'] = drupal_get_form($form_id,$node);
        dvm($block);
        return $block;
        break;
      case 1:
        module_load_include('inc', 'node', 'node.pages');
        $node_type = 'svm_mail_groups';
        $form_id = $node_type . '_node_form';
        global $user;
        $node = new stdClass();
        $node ->uid = $user->uid;
        $node ->name = (isset($user->name) ? $user ->name: '');
        $node ->type = $node_type;
        $block['subject'] = t('Update Mail Statistics');
        $block['content'] = drupal_get_form($form_id,$node);
        dvm($block);
        return $block;
        break;
    }
    break;
}
 }
}

1 Answer 1

1

When using my case statements for my form entities, I forgot to add in a break;

It all works nicely now!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.