私はdrupalを初めて使用するので、成功したログインフォームを作成する必要があります。しかし、ログインしているときに、フォームを別のフォームに切り替えて、詳細を編集できるようにします。
フォーム間を切り替える方法を見つけるのに苦労しています。
<?php
/**
* Implements hook_help.
*
* Displays help and module information.
*
* @param path
* Which path of the site we're using to display help
* @param arg
* Array that holds the current path as returned from arg() function
*/
function login_kms_help($path, $arg) {
switch ($path) {
case "admin/help#login":
return '<p>'. t("Creates login module") .'</p>';
break;
}
}
/**
* Implements hook_block_info().
*/
function login_kms_block_info() {
$blocks['login_kms'] = array(
'info' => t('Login KMS'), //The name that will appear in the block list.
'cache' => DRUPAL_CACHE_PER_ROLE, //Default
);
return $blocks;
}
function login_kms_block_view($delta = '') {
$block = array();
if($delta == 'login_kms') {
$block['subject'] = 'Login';
$block['content'] = drupal_render(drupal_get_form('login_kms_form_mode0'));
} else if($delta == 'login_kms'){
$block['subject'] = 'Edit';
$block['content'] = drupal_render(drupal_get_form('login_kms_form_mode1'));
}
return $block;
}
function login_kms_form_mode0() {
$form['username'] = array(
'#type' => 'textfield',
'#title' => t('Username:'),
);
$form['password'] = array(
'#type' => 'password',
'#title' => t('Password:'),
);
$form['Log in'] = array(
'#type' => 'submit',
'#value' => t('Log in'),
);
return $form;
}
function login_kms_form_mode1(){
$form['username'] = array(
'#type' => 'textfield',
'#title' => t('mode1'),
);
}
function login_kms_form_submit($form, &$form_state) {
$mysql_user = $form_state['values']['username'];
$mysql_pass = $form_state['values']['password'];
// drupal_set_message(t($mysql_pass));
// some logic
}