如何将名称文本字段添加并保存到简单的新闻块

发布于 2024-12-03 21:52:26 字数 597 浏览 4 评论 0原文

我知道以前曾问过类似的问题,但问题是它没有完整回答我的问题 在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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

三生殊途 2024-12-10 21:52:26

您不应该将字段添加到另一个模块中的现有表中,因为这可能会在升级时造成破坏。而是使用 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文