所以我认为我在概念上几乎就在那里,但需要一些缺失的指针。
目标是在普通用户注册表单中添加更多字段,对其进行一些样式设置,然后将额外字段存储在表格中进行提交。
这就是我到目前为止所拥有的。有人可以给我最后的推动,让我继续前进。请帮我。另外我如何应用一些小的样式,比如对齐新的表单域?
非常感谢 !!!!!!!!!
function module_menu() {
$items = array();
$items['school/registration'] = array(
'title' => 'Upgraded Registration Form',
'page callback' =>'module_school_register',
'type' => MENU_CALLBACK
);
return $items;
}//end of the function
function module_school_register(){
return drupal_get_form('form_school_register');
}//end of the function
function module_school_form_alter(&$form, $form_state, $form_id)
{
dsm($form_id);
if ($form_id == 'user_registration_form')
{
// modify the "#submit" form property by prepending another submit handler array
$form['#submit'] = array_merge(
array('_module_registration_submit' => array()),
$form['#submit']
);
}
}
function _module_registration_submit($form_id, $form_values) {
// store extra data in different table
}
function module_registration_validate($form, &$form_state)
{
$error=0;
//Validation stuff here, set $error to true if something went wrong, or however u want to do this. Completely up to u in how u set errors.
if ($error)
{
form_set_error('new_field_name', 'AHH SOMETHING WRONG!');
}
}