module_form_alter フックを使用してカスタム登録フォームを作成しました。また、必要な新しいフィールドを db_add_field でデータベースに追加しました。ユーザー登録/ユーザープロファイル編集でテーブルに値を追加できるようになり、値もデータベースに保存されます..しかし、私ができないのは、データベースに保存されている値を取得することです.ユーザープロファイル編集フォームに が表示されます。フォームのロード時にデータベースからフォームに値をロードするためのフックはありますか? それとも他に方法はありますか?
function customUser_schema_alter(&$schema) {
// Add field to existing schema.
$schema['users']['fields']['detail'] = array(
'type' => 'varchar',
'length' => 100,
);
}
function customUser_install() {
$schema = drupal_get_schema('users');
db_add_field('users', 'detail', $schema['fields']['detail']);
}
function customUser_form_alter(&$form, &$form_state, $form_id) {
// check to see if the form is the user registration or user profile form
// if not then return and don’t do anything
if (!($form_id == 'user_register_form' || $form_id == 'user_profile_form')) {
return;
}
$form['account']['detail'] = array(
'#type' => 'textfield',
'#title' => t('Additional Detail'),
);
}