需要将此代码放在自定义模块中,在Drupal7中,您可以在主题中执行类似的操作。是否有用于用户注册的默认temlpate?tpl.php?在某个地方你只能改变它? MYMODULE_form_user_profile_form_alter(&$fo
需要将此代码放在自定义模块中,在Drupal7中,您可以在主题中执行类似的操作。是否有用于用户注册的默认temlpate?tpl.php?在某个地方你只能改变它? MYMODULE_form_user_profile_form_alter(&$fo,drupal,overriding,registration,Drupal,Overriding,Registration,需要将此代码放在自定义模块中,在Drupal7中,您可以在主题中执行类似的操作。是否有用于用户注册的默认temlpate?tpl.php?在某个地方你只能改变它? MYMODULE_form_user_profile_form_alter(&$form, $form_state) { // do your processing here var_dump($form); } $form['name'] = array( '#type' => 'textfield', '#
需要将此代码放在自定义模块中,在Drupal7中,您可以在主题中执行类似的操作。是否有用于用户注册的默认temlpate?tpl.php?在某个地方你只能改变它?
MYMODULE_form_user_profile_form_alter(&$form, $form_state) {
// do your processing here
var_dump($form);
}
$form['name'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
'#weight' => 1,
);
$form['company'] = array(
'#type' => 'textfield',
'#title' => t('Company'),
'#weight' => 2,
);
$form['email'] = array(
'#type' => 'textfield',
'#title' => t('E-mail address'),
'#weight' => 3,
);
$form['personal'] = array(
'#type' => 'fieldset',
'#title' => t('Personal information'),
'#weight' => 1,
);
$form['personal']['name'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
'#weight' => 1,
);
$form['personal']['company'] = array(
'#type' => 'textfield',
'#title' => t('Company'),
'#weight' => 2,
);
$form['email'] = array(
'#type' => 'textfield',
'#title' => t('E-mail address'),
'#weight' => 3,
);
function test_form_alter(&$form, $form_state, $form_id) {
if ($form_id === 'user_register') { // Only modify the user registration form
// Before you can get down to business, you need to figure out the
// structure of the user registration form. Use var_dump or kpr to dump
// the $form array.
// Note: if you want to use kpr on the user registration form, give
// anonymous permission to see devel information.
// kpr($form);
// Move Name field to after E-Mail field
$form['name']['#weight'] = 2;
$form['mail']['#weight'] = 1;
// Group Name and E-mail together into a fieldset
$form['personal_info'] = array(
'#type' => 'fieldset',
'#title' => t('Personal information'),
);
$form['personal_info']['name'] = $form['name'];
$form['personal_info']['mail'] = $form['mail'];
// The last block only copied the elements: unset the old ones.
unset($form['name']);
unset($form['mail']);
}
}
function d6_forms_theme() {
return array(
'user_register' => array(
'template' => 'templates/user-register-form',
'arguments' => array('form' => NULL),
),
);
}
<?php
// What is in that $form var ? To check, uncomment next line
// print '<pre>' . print_r($form, 1) . '</pre>';
?>
<div style="background-color:#ddd;padding:10px;">
<?php print drupal_render($form['name']); ?>
<?php print drupal_render($form['mail']); ?>
</div>
<div>
<?php print drupal_render($form['submit']); ?>
</div>
<?php print drupal_render($form); ?>