检索 form_alter 的 cck 字段
我想在我的表单中检索 cck 字段“field_info”,以便在用户提交时插入到另一个表中。这似乎不起作用。
//mymodule_form_alter() implemented
function mymodule_form_mysubmit{
$test = $form['field_info']['#value'];
//insert stuff code
}
代码有错误吗?
I would like to retrieve a cck field "field_info" in my form alter to insert into another table when user is submitting. This doesn't seem to work.
//mymodule_form_alter() implemented
function mymodule_form_mysubmit{
$test = $form['field_info']['#value'];
//insert stuff code
}
Is there any mistake in the code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您说
module_form_alter()
已实现,但只是为了确认,您需要其中包含以下内容:假设您这样做,要获取 field_info 的值,您的提交函数应如下所示:
$form_state
包含正在提交的表单的当前状态。 CCK 始终假设一个字段可能有多个值,因此它总是将内容放入数组中(因此['field_info'][0]
)。You say
module_form_alter()
is implemented, but just to confirm, you need to have the following in it:Assuming you do, to get the value of field_info, your submit function should look like:
$form_state
contains the current state of the form being submitted. CCK always assumes that there could be multiple values for a field, so it always puts things in an array (hence['field_info'][0]
).我找到了解决方案
I found the solution