Drupal的表单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>我需要内部跨度标签,以便我可以使用滑动门CSS技术。
我想我需要从form.inc重写theme_button($element),但是到目前为止我的尝试都没有成功。
发布于 2008-11-07 07:49:47
如果你正在使用一个普通的form_foo主题(比如Chameleon),那么主题化PHP的基本思想是编写一个名为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
发布于 2008-11-07 09:42:47
我现在有一个类似如下的函数:
function mytheme_button($element) {
return "<button><span></span></button>"; # lots of code missing here for clarity
}为了让它正常工作,我简单地清除了缓存,Drupal注意到并自动使用了它。
https://stackoverflow.com/questions/268496
复制相似问题