drupal 7 をインストールし、カスタム フォームを作成しようとしています。試行中の以下のコードはhttp://drupal.org/node/717722から取得したもので、.info ファイル以外は変更していません。
ここに my_module.info があります
name = My module
description = Module for form api tutorial
core = 7.x
以下は my_module.module です
<?php
/**
* This function defines the URL to the page created etc.
* See http://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;
}
?>
これら 2 つのファイルを *my_module* フォルダーに配置し、sites/all/modulesに配置しました 。その後、エラーや警告なしでモジュール ページからモジュールを有効にしました。
ここで、URL を使用してこれにアクセスしようとすると、localhost/d7/?q=my_module/form
「ページが見つかりません」というエラーが表示されます..!! どうして..??私は何が欠けています..?
このモジュールだけでなく、この例の開発者モジュールhttp://drupal.org/project/examplesも対象です。同じエラーが表示されます。