gpt4 book ai didi

jquery - Drupal/jQuery/CSS::Wrap 单选按钮标签在 span 标签中?

转载 作者:太空宇宙 更新时间:2023-11-04 16:19:19 25 4
gpt4 key购买 nike

在 Drupal 中呈现单选按钮时,它的结果如下:

<label class="form-radio" for="sample">
<input type="radio" name="samp" value="1" />Sample
</label>

我一直在研究主题功能(即 theme_radiostheme_form_element ,但无法弄清楚如何呈现像

这样的输出
<label class="form-radio" for="sample">Sample</label>
<input type="radio" name="samp" value="1" />.

有人能指出我正确的方向吗?一直在梳理论坛,但没有找到任何帮助...我什至对 jquery 解决方案感到满意...

最佳答案

听起来您很接近 - 以单个 radio 输入为主题的函数是 theme_radio(不是 theme_radios,它存在但不同)。

为此,请根据 theme_radio 在主题的 template.php 中创建覆盖函数,即

<?php
function mytheme_radio($element) {
_form_set_class($element, array('form-radio'));
$output = '<input type="radio" ';
$output .= 'id="' . $element['#id'] . '" ';
$output .= 'name="' . $element['#name'] . '" ';
$output .= 'value="' . $element['#return_value'] . '" ';
$output .= (check_plain($element['#value']) == $element['#return_value']) ? ' checked="checked" ' : ' ';
$output .= drupal_attributes($element['#attributes']) . ' />';
if (!is_null($element['#title'])) {
$output = '<label class="option" for="' . $element['#id'] . '">' . $element['#title'] . '</label>' . $output;
}

unset($element['#title']);
return theme('form_element', $element, $output);
}
?>

(这适用于/includes/form.inc 中的任何主题功能;请记住以您的主题命名覆盖功能。)假设您根据发送的链接使用 Drupal 6。

关于jquery - Drupal/jQuery/CSS::Wrap 单选按钮标签在 span 标签中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6901071/

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