Drupal/jQuery/CSS ::包裹span标签中的单选按钮标签?
当一个单选按钮在Drupal呈现,它出来,如:Drupal/jQuery/CSS ::包裹span标签中的单选按钮标签?
<label class="form-radio" for="sample">
<input type="radio" name="samp" value="1" />Sample
</label>
我一直在寻找的主题化的功能(即theme_radios和theme_form_element,但无法弄清楚如何使类似的输出
<label class="form-radio" for="sample">Sample</label>
<input type="radio" name="samp" value="1" />.
有人点我在正确的方向?被梳理的论坛,但没有发现任何帮助......我甚至很高兴有一个jQuery的解决方案...
你可以尝试一下S中的页面之后载入
$(function(){
$("lable.form-radio").each(function(){
$(this).after($(this).find("input[name=samp]"));
});
});
听起来你很接近—主题化一个单无线电输入功能是theme_ 无线电(不theme_radio 小号,其存在,但不同)。
要做到这一点,创建基于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。
@KumbaThought - 不要使用jQuery,请!使用强大的Drupal主题覆盖系统,避免在页面加载后执行操作。将我的代码添加到您的template.php并清空缓存。有用! – DefiniteIntegral
问题的另一个解决方案“如何通过标签内部的css输入收音机造型?”对于引导主题的问题)) 我们可以在这个文件包的无线标签”标题:
网站/所有/主题/引导/模板/系统/表单元素label.func.php
在线路与$output
加到$title
span标记行70,80,89
例如$output .= '<span>' . $title . '</span>';
3天为寻求答案))
道歉......生活偷走了我从我的电脑上一阵了。感谢您的帮助 – KumbaThought