如何将名称文本字段添加并保存到简单的新闻块
我知道以前曾问过类似的问题,但问题是它没有完整回答我的问题 在drupal中如何将名称文本字段添加到简单新闻块
function mymodule_simplenews_block_form_submit($form, &$form_state) {
if ($form['#id'] == 5) {
$name = $form_state['values']['name'];
// Do something here to store the name in the database
// ...
// ...
}
}
我不明白与“在此处执行某些操作来存储名称”有关的部分在数据库中” 。首先,我应该将 name 字段添加到 simplenews_subscribers 表中吗?如何将名称字段保存在数据库中?我知道有一个 simplenews_realname 模块,但它适用于 Drupal 6。
谢谢!
I know that a similar question has been asked before but the problem that it doesn't have a complete answer for my question In drupal how to add name textfield to simple news block
function mymodule_simplenews_block_form_submit($form, &$form_state) {
if ($form['#id'] == 5) {
$name = $form_state['values']['name'];
// Do something here to store the name in the database
// ...
// ...
}
}
I don't get the part which has to do with "Do something here to store the name in the database" . First, Should I add the name field to the simplenews_subscribers table ? How can I save the name field in the database ? I know that there is a simplenews_realname module but it is for Drupal 6.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不应该将字段添加到另一个模块中的现有表中,因为这可能会在升级时造成破坏。而是使用 hook_schema 并将数据保存在那里。
如果您不熟悉构建 Drupal 模块,此模块开发人员指南将会有所帮助。
You shouldn't add a field to an existing table in another module as this will likely break things when the time comes to upgrade. Instead create your own table in a custom module using hook_schema and save the data there.
This module developer's guide will help if you're new to building Drupal modules.