0

菜单回调

function content_form_select($id, $sid){
    $type = check_content_type($sid);
    if($type == 'video')
        // Render content edit form
        return drupal_get_form('content_video_form', $id, $sid);
    else if($type == 'gallery')
        // Render content edit form
        return drupal_get_form('content_gallery_form', $id, $sid);
}

视频表格生成器

function content_video_form($id=null, $sid=null){
    return array('#value' => 'Video form is getting rendered.');
}

图库表单生成器

function content_gallery_form($id=null, $sid=null){
    return array('#value' => 'Gallery form is getting rendered.');
}

它不会以这种方式呈现形式

4

1 回答 1

1

drupal_get_form 期望接收一个 $form 数组,然后包含表单元素。使用上面的示例函数之一,以下更改对我有用:

function content_gallery_form($id=null, $sid=null){
  $form['example'] = array('#value' => 'Gallery form is getting rendered.');
  return $form;
}
于 2011-01-27T04:12:10.830 回答