gpt4 book ai didi

drupal - Drupal-将类添加到所有提交按钮

转载 作者:行者123 更新时间:2023-12-04 19:45:37 27 4
gpt4 key购买 nike

我的网页中有几种表单,并且我希望能够向所有提交按钮添加一个类(现在我已经将表单提交作为标准)。而且,在某些表单中,我具有使用AHAH来显示内容的按钮,但我不希望这些按钮具有新类,仅希望那些在表单上进行最终提交的按钮具有新类。

提前致谢!

最佳答案

或者,您可以覆盖负责提交按钮的theme_button。将其放置在template.php文件中,并确保在进行更改后清除缓存。您可以var_dump $element并查看如何区分提交按钮。

/**
* Overwrite theme_button()
* @file template.php
* !replace my_theme with the name of your active theme
*/
function my_theme_button($element) {

// Add some extra conditions to make sure we're only adding
// the classto the right submit button
if ($element['#id'] == 'edit-submit') {
// Now add our custom class
if (isset($element['#attributes']['class'])) {
$element['#attributes']['class'] .= ' extra-class';
}
else {
$element['#attributes']['class'] = 'extra-class';
}
}

return theme_button($element);
}

关于drupal - Drupal-将类添加到所有提交按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8602067/

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