gpt4 book ai didi

php - 如何在 Drupal 中为 Form API 按钮设置主题?

转载 作者:行者123 更新时间:2023-12-02 07:57:01 25 4
gpt4 key购买 nike

Drupal 的 Form API 的默认输出是:

<input id="edit-submit" class="form-submit" type="submit" value="Save" name="op"/>

我如何设置主题以便我得到:

<button id="edit-submit" class="form-submit" type="submit">
<span>Save</span>
</button>

我需要内部 span-tag 以便我可以使用滑动门 CSS 技术。

我想我需要覆盖 form.inc 中的 theme_button($element),但到目前为止我的尝试没有成功。

最佳答案

如果您使用的是纯 PHP 主题(如 Chameleon),则为 form_foo 设置主题的基本思想是编写一个名为 theme_form_foo() 的函数。

您还可以专门为一个元素(如此按钮)设置主题,方法是为其声明一个主题函数。参见 https://api.drupal.org/api/drupal/developer%21topics%21forms_api_reference.html/7

请注意,对于 D6,在这两种情况下,您都需要在主题注册表中声明函数,否则 Drupal 不会注意到此覆盖。这在 D5 中不是必需的。如果您使用的是 phptemplate,那么您也需要它,尽管 PHPtemplate 会处理表单大小写之外的注册表:http://drupal.org/node/132442#theme-registry

这方面的文档可在 a.d.o. 上找到。 : http://api.drupal.org/api/file/developer/topics/forms_api.html

关于php - 如何在 Drupal 中为 Form API 按钮设置主题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/268496/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com