Drupal Studs 帮助我完成我的 form_alter 钩子(我快到了) [英] Drupal Studs help me with my form_alter hook ( I am almost there)
问题描述
所以我想我几乎在概念上就完成了,但需要一些缺失的指针.
So I think I am almost there conceptually but need some missing pointers.
目标是在普通用户注册表单中添加更多字段,稍微设置样式,然后提交,将额外的字段存储在表格中.
Objective is to add a few more fields to the normal user registration form, style it a little, then submit it with storing the extra fields in a table.
这是我目前所拥有的.有人可以给我最后的推动并让我继续前进.请帮我.另外我如何应用一些小的样式,比如对齐新的表单字段?
This is what I have so far. Can someone give me the final nudge and get me going. Please help me. Also how do I apply some minor styling like aligning the new form fields ?
非常感谢!!!!!!!!!
Thank you so much !!!!!!!!!
function module_menu() {
$items = array();
$items['school/registration'] = array(
'title' => 'Upgraded Registration Form',
'page callback' =>'module_school_register',
'type' => MENU_CALLBACK
);
返回 $items;}//函数结束
return $items; }//end of the function
function module_school_register(){return drupal_get_form('form_school_register');}//函数结束
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){
function module_school_form_alter(&$form, $form_state, $form_id) {
dsm($form_id);
dsm($form_id);
if ($form_id == 'user_registration_form'){//通过添加另一个提交处理程序数组来修改#submit"表单属性$form['#submit'] = array_merge(数组('_module_registration_submit' => 数组()),$form['#submit']);
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) {//在不同的表中存储额外的数据}
function _module_registration_submit($form_id, $form_values) { // store extra data in different table }
function module_registration_validate($form, &$form_state){$错误=0;//这里的验证内容,如果出现问题,则将 $error 设置为 true,或者您想这样做.完全取决于您如何设置错误.如果($错误){form_set_error('new_field_name', 'AHH 出问题了!');}}
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!'); } }
推荐答案
我建议您在推出自己的解决方案之前先查看内容配置文件模块.
I suggest you have a look at content profile module before rolling your own solution.
您为学校注册定义自定义内容类型(节点),添加您的 cck 字段,并将其激活为内容配置文件.在内容配置文件设置中,您可以在用户注册表中激活它.零代码!
You define your a custom content type (node) for your school registration, add in you cck fields, and activate it as a content profile. On content profile settings, you then activate it on user registration form. Zero code !
这篇关于Drupal Studs 帮助我完成我的 form_alter 钩子(我快到了)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!