Car*_*nal 2 drupal form-submit drupal-6
我的网页上有几个表单,我希望能够在我的所有提交按钮中添加一个类(现在我已经将表单提交为标准).而且,在某些形式中,我有一个按钮,它使用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);
}
Run Code Online (Sandbox Code Playgroud)