2012-02-19 3 views
3

나는 드루팔 7을 설치하고 사용자 지정 양식을 만들려고하고 있습니다. 아래 코드는 http://drupal.org/node/717722에서 가져 왔으며 .info 파일을 제외하고는 변경하지 않았습니다. 여기 드루팔 (Drupal 7의 간단한 예제 폼)에 올바르게 구성된 모든 것이 "페이지를 찾을 수 없음"을 보여줍니다. 왜 ..?

내가/모든 사이트에서 그것을는 * my_module * 폴더에이 두 파일을 배치하고 배치 한 my_module.module

<?php 

/** 
* This function defines the URL to the page created etc. 
* See http&#58;//api.drupal.org/api/function/hook_menu/6 
*/ 
function my_module_menu() { 
    $items = array(); 
    $items['my_module/form'] = array(
    'title' => t('My form'), 
    'page callback' => 'my_module_form', 
    'access arguments' => array('access content'), 
    'description' => t('My form'), 
    'type' => MENU_CALLBACK, 
); 
    return $items; 
} 

/** 
* This function gets called in the browser address bar for: 
* "http://yourhost/my_module/form" or 
* "http://yourhost/?q=my_module/form". It will generate 
* a page with this form on it. 
*/ 
function my_module_form() { 

    // This form calls the form builder function via the 
    // drupal_get_form() function which takes the name of this form builder 
    // function as an argument. It returns the results to display the form. 
    return drupal_get_form('my_module_my_form'); 

} 

/** 
* This function is called the "form builder". It builds the form. 
* Notice, it takes one argument, the $form_state 
*/ 
function my_module_my_form($form_state) { 

// This is the first form element. It's a textfield with a label, "Name" 
    $form['name'] = array(
    '#type' => 'textfield', 
    '#title' => t('Name'), 
); 
    return $form; 
} 

?> 

my_module.info 아래

name = My module 
description = Module for form api tutorial 
core = 7.x 

입니다/모듈 그 후 , 나는 오류 또는 경고없이 모듈 페이지에서 모듈을 활성화. 내가 URL을 사용하는 localhost/d7/?q=my_module/form

을이 액세스 할 때 이제

, 나는 "페이지를 찾을 수 없습니다"오류가 발생합니다 .. !! 왜..?? 나는 무엇을 놓치고 ..? 이 모듈뿐만 아니라 개발자 모듈 http://drupal.org/project/examples이 예제뿐만 아니라

그것. 같은 오류를 보여줍니다.

+2

당신은'관리/설정/개발/performance'에서 캐시를 지우나요? – nmc

+0

정말 고마워요 !! !! 그게 내가 잘못 가고있는 곳이야. :) – akshaynhegde

답변

0

당신이 작성해야 : my_module 모듈 이름

$items['my_module'] 

입니다.
는 그리고 당신은

sites/all/theme/your_theme/template/page-my_module_my_form.tpl.php 

에서 page-my_module_my_form.tpl.php 파일을 작성해야하고이 파일에 다음과 같은 코드를 추가

<?php 

if (isset($form['submission_info']) || isset($form['navigation'])) { 
    print drupal_render($form['navigation']); 
    print drupal_render($form['submission_info']); 
} 

print drupal_render($form['submitted']); 

?> 

<?php print drupal_render_children($form); ?> 

과 함께 실행하려고

로컬 호스트/D7/my_module

나는이 뜻을 희망 당신에게 유용

0

나는이 늦게 알아,하지만 난 당신이 $ 양식 변수, 양식에 전달과 같이 가질 필요가 있다고 생각합니까 :
기능 my_module_my_form ($ form_state, $ 양식) ...
그 양식 데이터를 보관할 양식 변수가 실제로있는 것입니다.