i'm using Drupal 6.19 , in order to do some changes to the forms i followed some tutorials on the web using the form_alter hook . well identifying the form consist of testing $form_id (that worked fine) ,but adding new fields is done by manipulating the $form variable . when i tried this on my code it didn't work ,so i tried to manipulate the $form_id variable instead and it worked ! i know that my problem is solved but i want to know what the difference between $form_id and $form ? isn't $form_id suppose to store only the form identifier ? and the form content goes into $form ?
2条回答 默认 最新
- douwen3965 2011-02-10 19:04关注
ok, here is my code for the form_alter hook : btw, i use dBug to view the content of variables (that's how i figured out that $form does'nt contain the form structure)
function testymodule_form_alter($form_id, &$form) { include_once("dBug.php"); if ($form_id['#id']=='node-form') { $form_id['testymodule_checkbox'] = array( '#type' => 'checkbox', '#title' => t('Newly testy Checkbox'), ); new dBug($form_id); }
this will add a new checkbox to the mentioned form (although it maniuplate $form_id not $form)
what i found on the net was manipulating $form :
function testymodule_form_alter($form_id, &$form) { include_once("dBug.php"); if ($form_id['#id']=='node-form') { $form['testymodule_checkbox'] = array( //here is the clue '#type' => 'checkbox', '#title' => t('Newly testy Checkbox'), ); new dBug($form_id); }
it's weird nan ?
解决 无用评论 打赏 举报
悬赏问题
- ¥20 win11修改中文用户名路径
- ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
- ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
- ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
- ¥15 帮我写一个c++工程
- ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
- ¥15 关于smbclient 库的使用
- ¥15 微信小程序协议怎么写
- ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
- ¥20 怎么用dlib库的算法识别小麦病虫害